Interface CloseableReadonlyBuffer<T>
-
- Type Parameters:
T- the type of messages in this buffer
- All Known Subinterfaces:
CloseableBuffer<T>,DisposableReadonlyBuffer<T>
- All Known Implementing Classes:
BlockingCloseableBuffer,FlowControlledDisposableReadonlyBuffer,RoundRobinMultiReadonlyBuffer
public interface CloseableReadonlyBuffer<T>A readonly buffer that can be closed from the producing side.- Since:
- 4.6.0
- Author:
- Milan Savic, Stefan Dragisic, Allard Buijze
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description intcapacity()Returns the overall capacity of this buffer.booleanclosed()Indicates whether the buffer is closed by the producing side.Optional<ErrorMessage>error()Returns an error from this buffer, if any.booleanisEmpty()Indicates whether there are messages in the buffer.voidonAvailable(Runnable onAvailable)Registers an action to be triggered when there is a new message added to the buffer, or the buffer is closed, or the buffer is closed with an error.Optional<T>poll()Polls the message from this buffer.
-
-
-
Method Detail
-
poll
Optional<T> poll()
Polls the message from this buffer. If the returnedOptionalis empty, that doesn't mean that this buffer stays empty forever. Theclosed()method should be consolidated to validate this.- Returns:
- an
Optionalwith polled message
-
isEmpty
boolean isEmpty()
Indicates whether there are messages in the buffer. If this returnsfalse, that doesn't mean that this buffer stays empty forever. Theclosed()method should be consolidated to validate this.- Returns:
trueif buffer is empty,falseotherwise
-
capacity
int capacity()
Returns the overall capacity of this buffer.- Returns:
- the overall capacity of this buffer
-
onAvailable
void onAvailable(Runnable onAvailable)
Registers an action to be triggered when there is a new message added to the buffer, or the buffer is closed, or the buffer is closed with an error. The action can checkpoll(),closed(), anderror()to validate this.- Parameters:
onAvailable- to be invoked when there are changes in this buffer
-
closed
boolean closed()
Indicates whether the buffer is closed by the producing side.- Returns:
trueif closed,falseotherwise
-
error
Optional<ErrorMessage> error()
Returns an error from this buffer, if any.- Returns:
- an
Optionalof an error, if any
-
-