cassandra-pr mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jonmeredith <...@git.apache.org>
Subject [GitHub] cassandra pull request #288: In BufferPool, make allocating thread receive a...
Date Mon, 26 Nov 2018 17:58:10 GMT
Github user jonmeredith commented on a diff in the pull request:

    https://github.com/apache/cassandra/pull/288#discussion_r236362932
  
    --- Diff: src/java/org/apache/cassandra/utils/memory/BufferPool.java ---
    @@ -237,23 +237,25 @@ void check()
             /** Return a chunk, the caller will take owership of the parent chunk. */
             public Chunk get()
             {
    -            while (true)
    -            {
    -                Chunk chunk = chunks.poll();
    -                if (chunk != null)
    -                    return chunk;
    +            Chunk chunk = chunks.poll();
    +            if (chunk != null)
    +                return chunk;
     
    -                if (!allocateMoreChunks())
    -                    // give it one last attempt, in case someone else allocated before
us
    -                    return chunks.poll();
    -            }
    +            chunk = allocateMoreChunks();
    +            if (chunk != null)
    +                return chunk;
    +
    +            /*  another thread may have just allocated last macro chunk, so
    +            **  make one final attempt before returning null
    --- End diff --
    
    thx for the pointers, updated to a single line.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


Mime
View raw message