Interface SharedReference<T>

  • Type Parameters:
    T - the type of the represented object
    All Superinterfaces:
    Serializable

    public interface SharedReference<T>
    extends Serializable
    Represents an object managed in a SharedObjects. The reference can be serialized and will still point to the same instance after deserialization in the same JVM. The underlying object may change the state but this reference will never point to another object.
    • Method Detail

      • get

        T get()
        Returns the referenced object without giving any visibility guarantees. This method should only be used on thread-safe classes.
      • applySync

        default <R> R applySync​(Function<T,​R> function)
        Executes the code on the referenced object in a synchronized fashion. Note that this method is prone to deadlock if multiple references are accessed in a synchronized fashion in a nested call-chain.
      • consumeSync

        default void consumeSync​(Consumer<T> consumer)
        Executes the code on the referenced object in a synchronized fashion. Note that this method is prone to deadlock if multiple references are accessed in a synchronized fashion in a nested call-chain.