public abstract class BrooklynDslDeferredSupplier<T> extends java.lang.Object implements DeferredSupplier<T>, ImmediateSupplier<T>, TaskFactory<Task<T>>, java.io.Serializable
DeferredSupplier
so that they can be resolved when needed
(e.g. when entity-lookup and execution contexts are available).
Implementations of this abstract class are expected to be immutable and thread safe,
as instances must support usage in multiple Assembly
instances
created from a single AssemblyTemplate
. The object can be used in parallel
from multiple threads and no locking is done as all extending objects are assumed to be stateless.
Subclasses which return a deferred value are typically only
resolvable in the context of a Task
on an Entity
;
these should be only used as the value of a ConfigKey
set in the YAML,
and should not accessed until after the components / entities are created
and are being started.
(TODO the precise semantics of this are under development.)
The threading model is that only one thread can call get()
at a time. An interruptible
lock is obtained using #lock
for the duration of that method. It is important to not
use synchronized
because that is not interruptible - if someone tries to get the value
and interrupts after a short wait, then we must release the lock immediately and return.
ImmediateSupplier.ImmediateUnsupportedException, ImmediateSupplier.ImmediateValueNotAvailableException
Constructor and Description |
---|
BrooklynDslDeferredSupplier() |
Modifier and Type | Method and Description |
---|---|
T |
get() |
abstract Task<T> |
newTask() |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getImmediately
public final T get()
get
in interface DeferredSupplier<T>