A Reference with queue semantics where the current reference may be retrieved
or taken instead, and if there is no current element then it will be block
until the reference becomes available. This is somewhat analogous to a single
element
BlockingQueue.
Note: this class does not support null elements being
#set(Object)and will throw an exception. If the internal reference is null, then calls to
#take() or
#take(long,TimeUnit) will block.
This class is most suited to
#newSRSW() or
#newMRSW() usage. Multiple writers will overwrite each other's elements and the
chosen value will be arbitrary in the absence of any external consensus. If
multiple readers are waiting to
#take() a value, one reader will be
arbitrarily chosen (similar to
Condition#signal()). Multiple readers
can however
#get() the current value if it is not null, but they may
see the current value more than once. If multiple readers attempt to
#get() a value from the SRSW reference and it is not yet present then
only one waiting thread may be notified, please use the MRSW version for this
case.
This implementation has been optimized for SRSW performance with
#set(Object)/
#take() pairs.
Prometheus contains a similar construct called an AwaitableReference. This class is more explicit in that it handles
take/get separately.