Interface Reference<T>

Type Parameters:
T - the referenced type
All Superinterfaces:
ReadableReference<T>

public interface Reference<T> extends ReadableReference<T>
Encapsulates a thread-safe read/write reference to an object. Semantically analogous to AtomicReference, but uses read/write locks instead of CAS operations.
Author:
Paul Ferraro
  • Method Details

    • writer

      default Reference.Writer<T> writer(T value)
      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

      default Reference.Writer<T> writer(Supplier<T> supplier)
      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

      Reference.Writer<T> writer(UnaryOperator<T> updater)
      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

      static <T> Reference<T> of(T initialValue)