Current size of the buffer.
Current size of the buffer.
The returned value is only quiescently consistent; treat it as a fast approximation.
Try to get an item out of the ConcurrentRingBuffer.
Try to get an item out of the ConcurrentRingBuffer. Returns no item only when the buffer is empty.
Returns the next element without changing the read position.
Returns the next element without changing the read position.
the next element or None if buffer is empty
Attempt to put an item into the buffer.
Attempt to put an item into the buffer. If it is full, the operation fails.
A simple, lock-free, non-blocking ring buffer.
This differs from com.twitter.util.RingBuffer in that it is simpler (fewer features), and is fully concurrent (and hence also threadsafe). This should probably be moved into util at some point.
Note: For very high-rate usages, sizing buffers by powers of two may be advantageous.
Caveats: References are kept to old entries until they are overwritten again. You can get around this by storing nullable references (though this would require another allocation for each item).