Package org.apache.flink.testutils.junit
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 aSharedObjects
. 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 Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default <R> R
applySync(Function<T,R> function)
Executes the code on the referenced object in a synchronized fashion.default void
consumeSync(Consumer<T> consumer)
Executes the code on the referenced object in a synchronized fashion.T
get()
Returns the referenced object without giving any visibility guarantees.
-
-
-
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.
-
-