Package net.officefloor.frame.test
Class ThreadSafeClosure<T>
java.lang.Object
net.officefloor.frame.test.ThreadSafeClosure<T>
- Author:
- Daniel Sagenschneider
-
Constructor Summary
ConstructorsConstructorDescriptionInitialise withnull.ThreadSafeClosure(T initialValue) Initialise with initial value. -
Method Summary
Modifier and TypeMethodDescriptionvoidFlags a failure.get()Obtains current value.voidSets the value.Convenience method to wait 3 seconds and then get value.waitAndGet(long timeout) Obtains the value.
-
Constructor Details
-
ThreadSafeClosure
public ThreadSafeClosure()Initialise withnull. -
ThreadSafeClosure
Initialise with initial value.- Parameters:
initialValue- Initial value.
-
-
Method Details
-
set
Sets the value.- Parameters:
value- Value.
-
failure
Flags a failure.- Parameters:
cause- Cause of the failure.
-
get
Obtains current value.- Returns:
- Value or
null.
-
waitAndGet
Convenience method to wait 3 seconds and then get value.- Returns:
- Value.
-
waitAndGet
Obtains the value.- Parameters:
timeout- Timeout to wait for the value.- Returns:
- Value.
-