Interface BlockingReference<T>
- Type Parameters:
T- the referenced type
- All Superinterfaces:
Reference<T>
Encapsulates thread-safe reading/writing on an object reference.
Analogous to
AtomicReference, but uses read/write locks instead of CAS operations.- Author:
- Paul Ferraro
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classA conditional writer implementation for a reference.static classA writer implementation for a reference.static interfaceDescribes the writer of a reference.Nested classes/interfaces inherited from interface Reference
Reference.Reader<T>, Reference.ReferenceReader<T,V> -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> BlockingReference<T> of(T initialValue) Returns a blocking reference with the specified initial value.default BlockingReference.Writer<T> Returns a thread-safe writer of this reference.writer(UnaryOperator<T> updater) Returns a thread-safe writer of this reference.default BlockingReference.Writer<T> Returns a thread-safe writer of this reference.
-
Method Details
-
writer
Returns a thread-safe writer of this reference.- Parameters:
value- the target value of this reference- Returns:
- a thread-safe reader of this reference.
-
writer
Returns a thread-safe writer of this reference.- Parameters:
supplier- supplier of the target value of this reference- Returns:
- a thread-safe reader of this reference.
-
writer
Returns a thread-safe writer of this reference.- Parameters:
updater- operator returning the target value of this reference based on the current value- Returns:
- a thread-safe reader of this reference.
-
of
Returns a blocking reference with the specified initial value.- Type Parameters:
T- the referenced object type- Parameters:
initialValue- the initial value of the returned reference- Returns:
- a blocking reference with the specified initial value.
-