ReadOneAsync Method
ReadOneAsync(Int64)
Reads one item from the Ringbuffer.
Declaration
ValueTask<TItem> ReadOneAsync(long sequence)
Parameters
Int64 | sequence | the sequence of the item to read. |
Returns
ValueTask<TItem> | the read item |
Remarks
Reads one item from the Ringbuffer. If the sequence is one beyond the current tail, this call blocks until an item is added. This means that the ringbuffer can be processed using the following idiom:
Ringbuffer<String> ringbuffer = hz.GetRingbuffer("rb");
long seq = ringbuffer.HeadSequence();
while(true){
String item = ringbuffer.ReadOne(seq);
seq++;
... process item
}
This method is not destructive unlike e.g. a queue.take. So the same item can be read by multiple readers or it can be read multiple times by the same reader. Currently it isn't possible to control how long this call is going to block. In the future we could Add e.g. tryReadOne(long sequence, long timeout, TimeUnit unit).
Exceptions
ArgumentException | if sequence is smaller than 0 or larger than
|
Exception | if the call is interrupted while blocking. |