@java.lang.SuppressWarnings({"UnqualifiedStaticUsage", "CallToSimpleGetterFromWithinClass", "ConstantDeclaredInAbstractClass", "unchecked"}) public abstract class DataflowExpression extends WithSerialId
The base class for all dataflow elements.
Modifiers | Name | Description |
---|---|---|
static class |
DataflowExpression.BindDataflow |
Represents a remote message binding a value to a remoted DataflowExpression |
class |
DataflowExpression.DataflowExpressionsCollector |
Listener for availability of data flow expressions we depend on. |
private static class |
DataflowExpression.TransformMany |
|
private static class |
DataflowExpression.TransformOne |
|
private static class |
DataflowExpression.WaitingThread |
A logical representation of a synchronous or asynchronous request to read the value once it is bound. |
Modifiers | Name | Description |
---|---|---|
private static java.lang.String |
ATTACHMENT |
|
private static java.lang.String |
A_DATAFLOW_VARIABLE_CAN_ONLY_BE_ASSIGNED_ONCE_ONLY_RE_ASSIGNMENTS_TO_AN_EQUAL_VALUE_ARE_ALLOWED |
|
private static java.lang.String |
CANNOT_FIRE_BIND_ERRORS_THE_THREAD_HAS_BEEN_INTERRUPTED |
|
private static java.lang.String |
RESULT |
|
protected static int |
S_INITIALIZED |
|
protected static int |
S_INITIALIZING |
|
protected static int |
S_NOT_INITIALIZED |
Possible states |
private static DataflowExpression.WaitingThread |
dummyWaitingThread |
A request chain terminator |
protected java.lang.Throwable |
error |
|
private DataflowChannelEventOrchestrator<T> |
eventManager |
|
private groovy.lang.MetaClass |
metaClass |
The current metaclass |
private static long |
serialVersionUID |
|
protected int |
state |
Holds the current state of the variable |
protected static java.util.concurrent.atomic.AtomicIntegerFieldUpdater<DataflowExpression> |
stateUpdater |
Updater for the state field |
protected T |
value |
Holds the actual value. |
private DataflowExpression.WaitingThread |
waiting |
Points to the head of the chain of requests waiting for a value to be bound |
protected static java.util.concurrent.atomic.AtomicReferenceFieldUpdater<DataflowExpression, WaitingThread> |
waitingUpdater |
Updater for the waiting field |
Fields inherited from class | Fields |
---|---|
class WithSerialId |
serialHandle, serialVersionUID |
Constructor and description |
---|
DataflowExpression
() |
Type | Name and description |
---|---|
protected java.lang.Object |
DataflowExpression() Creates a new unbound Dataflow Expression |
void |
binaryChoice(DataflowWriteChannel<T> trueBranch, DataflowWriteChannel<T> falseBranch, groovy.lang.Closure<java.lang.Boolean> code) |
void |
binaryChoice(Pool pool, DataflowWriteChannel<T> trueBranch, DataflowWriteChannel<T> falseBranch, groovy.lang.Closure<java.lang.Boolean> code) |
void |
binaryChoice(PGroup group, DataflowWriteChannel<T> trueBranch, DataflowWriteChannel<T> falseBranch, groovy.lang.Closure<java.lang.Boolean> code) |
void |
binaryChoice(java.util.Map<java.lang.String, java.lang.Object> params, DataflowWriteChannel<T> trueBranch, DataflowWriteChannel<T> falseBranch, groovy.lang.Closure<java.lang.Boolean> code) |
void |
binaryChoice(Pool pool, java.util.Map<java.lang.String, java.lang.Object> params, DataflowWriteChannel<T> trueBranch, DataflowWriteChannel<T> falseBranch, groovy.lang.Closure<java.lang.Boolean> code) |
void |
binaryChoice(PGroup group, java.util.Map<java.lang.String, java.lang.Object> params, DataflowWriteChannel<T> trueBranch, DataflowWriteChannel<T> falseBranch, groovy.lang.Closure<java.lang.Boolean> code) |
void |
bind(T value) Assigns a value to the variable. |
void |
bindError(java.lang.Throwable e) |
void |
bindSafely(T value) Assigns a value to the variable. |
void |
bindUnique(T value) Assigns a value to the variable. |
DataflowReadChannel<V> |
chainWith(groovy.lang.Closure<V> closure) |
DataflowReadChannel<V> |
chainWith(Pool pool, groovy.lang.Closure<V> closure) |
DataflowReadChannel<V> |
chainWith(PGroup group, groovy.lang.Closure<V> closure) |
DataflowReadChannel<V> |
chainWith(java.util.Map<java.lang.String, java.lang.Object> params, groovy.lang.Closure<V> closure) |
DataflowReadChannel<V> |
chainWith(Pool pool, java.util.Map<java.lang.String, java.lang.Object> params, groovy.lang.Closure<V> closure) |
DataflowReadChannel<V> |
chainWith(PGroup group, java.util.Map<java.lang.String, java.lang.Object> params, groovy.lang.Closure<V> closure) |
void |
choice(java.util.List<DataflowWriteChannel<T>> outputs, groovy.lang.Closure<java.lang.Integer> code) |
void |
choice(Pool pool, java.util.List<DataflowWriteChannel<T>> outputs, groovy.lang.Closure<java.lang.Integer> code) |
void |
choice(PGroup group, java.util.List<DataflowWriteChannel<T>> outputs, groovy.lang.Closure<java.lang.Integer> code) |
void |
choice(java.util.Map<java.lang.String, java.lang.Object> params, java.util.List<DataflowWriteChannel<T>> outputs, groovy.lang.Closure<java.lang.Integer> code) |
void |
choice(Pool pool, java.util.Map<java.lang.String, java.lang.Object> params, java.util.List<DataflowWriteChannel<T>> outputs, groovy.lang.Closure<java.lang.Integer> code) |
void |
choice(PGroup group, java.util.Map<java.lang.String, java.lang.Object> params, java.util.List<DataflowWriteChannel<T>> outputs, groovy.lang.Closure<java.lang.Integer> code) |
private DataflowChannelEventOrchestrator<T> |
createEventManager() |
private void |
doBind(T value) Performs the actual bind operation, unblocks all blocked threads and informs all asynchronously waiting actors. |
protected void |
doBindImpl(T value) |
void |
doBindRemote(java.util.UUID hostId, T message) Binds the value after receiving a bing message over the wire |
private Promise<java.util.List> |
doThenForkAndJoin(PGroup group, Pool pool, groovy.lang.Closure<? extends java.lang.Object>[] closures) |
protected T |
evaluate() Evaluates the expression after the ones we depend on are ready |
DataflowReadChannel<T> |
filter(groovy.lang.Closure<java.lang.Boolean> closure) |
DataflowReadChannel<T> |
filter(Pool pool, groovy.lang.Closure<java.lang.Boolean> closure) |
DataflowReadChannel<T> |
filter(PGroup group, groovy.lang.Closure<java.lang.Boolean> closure) |
DataflowReadChannel<T> |
filter(java.util.Map<java.lang.String, java.lang.Object> params, groovy.lang.Closure<java.lang.Boolean> closure) |
DataflowReadChannel<T> |
filter(Pool pool, java.util.Map<java.lang.String, java.lang.Object> params, groovy.lang.Closure<java.lang.Boolean> closure) |
DataflowReadChannel<T> |
filter(PGroup group, java.util.Map<java.lang.String, java.lang.Object> params, groovy.lang.Closure<java.lang.Boolean> closure) |
private void |
fireBindError(T value, boolean unique) |
private void |
fireBindError(java.lang.Throwable e) |
private void |
fireOnMessage(T value) |
BindErrorListenerManager<T> |
getBindErrorManager() |
DataflowChannelEventListenerManager<T> |
getEventManager() |
groovy.lang.MetaClass |
getMetaClass() |
java.lang.Object |
getProperty(java.lang.String propertyName) Returns either standard property of the expression or creates an expression, which will request given property when the receiver becomes available |
T |
getVal() Reads the value of the variable. |
T |
getVal(long timeout, java.util.concurrent.TimeUnit units) Reads the value of the variable. |
void |
getValAsync(MessageStream callback) Asynchronously retrieves the value of the variable. |
void |
getValAsync(java.lang.Object attachment, MessageStream callback) Used by Dataflow operators. |
private static void |
handleInterruption(java.util.concurrent.atomic.AtomicBoolean newWaiting) |
void |
into(DataflowWriteChannel<T> target) |
void |
into(Pool pool, DataflowWriteChannel<T> target) |
void |
into(PGroup group, DataflowWriteChannel<T> target) |
void |
into(java.util.Map<java.lang.String, java.lang.Object> params, DataflowWriteChannel<T> target) |
void |
into(Pool pool, java.util.Map<java.lang.String, java.lang.Object> params, DataflowWriteChannel<T> target) |
void |
into(PGroup group, java.util.Map<java.lang.String, java.lang.Object> params, DataflowWriteChannel<T> target) |
java.lang.Object |
invokeMethod(java.lang.String name, java.lang.Object args) Invokes the method on itself or creates an expression, which will invoke the method n the bound value, once it is available. |
boolean |
isBound() Check if value has been set already for this expression |
void |
join() Blocks, if the value has not been assigned yet to the DataflowVariable |
void |
join(long timeout, java.util.concurrent.TimeUnit units) Blocks, if the value has not been assigned yet to the DataflowVariable |
int |
length() |
DataflowReadChannel<V> |
merge(DataflowReadChannel<java.lang.Object> other, groovy.lang.Closure<V> closure) |
DataflowReadChannel<V> |
merge(Pool pool, DataflowReadChannel<java.lang.Object> other, groovy.lang.Closure<V> closure) |
DataflowReadChannel<V> |
merge(PGroup group, DataflowReadChannel<java.lang.Object> other, groovy.lang.Closure<V> closure) |
DataflowReadChannel<V> |
merge(java.util.List<DataflowReadChannel<java.lang.Object>> others, groovy.lang.Closure<V> closure) |
DataflowReadChannel<V> |
merge(Pool pool, java.util.List<DataflowReadChannel<java.lang.Object>> others, groovy.lang.Closure<V> closure) |
DataflowReadChannel<V> |
merge(PGroup group, java.util.List<DataflowReadChannel<java.lang.Object>> others, groovy.lang.Closure<V> closure) |
DataflowReadChannel<V> |
merge(java.util.Map<java.lang.String, java.lang.Object> params, DataflowReadChannel<java.lang.Object> other, groovy.lang.Closure<V> closure) |
DataflowReadChannel<V> |
merge(Pool pool, java.util.Map<java.lang.String, java.lang.Object> params, DataflowReadChannel<java.lang.Object> other, groovy.lang.Closure<V> closure) |
DataflowReadChannel<V> |
merge(PGroup group, java.util.Map<java.lang.String, java.lang.Object> params, DataflowReadChannel<java.lang.Object> other, groovy.lang.Closure<V> closure) |
DataflowReadChannel<V> |
merge(java.util.Map<java.lang.String, java.lang.Object> params, java.util.List<DataflowReadChannel<java.lang.Object>> others, groovy.lang.Closure<V> closure) |
DataflowReadChannel<V> |
merge(Pool pool, java.util.Map<java.lang.String, java.lang.Object> params, java.util.List<DataflowReadChannel<java.lang.Object>> others, groovy.lang.Closure<V> closure) |
DataflowReadChannel<V> |
merge(PGroup group, java.util.Map<java.lang.String, java.lang.Object> params, java.util.List<DataflowReadChannel<java.lang.Object>> others, groovy.lang.Closure<V> closure) |
private void |
notifyRemote(java.util.UUID hostId) Sends notifications to all subscribers |
DataflowReadChannel<V> |
or(groovy.lang.Closure<V> closure) |
void |
or(DataflowWriteChannel<T> target) |
DataflowExpression<T> |
poll() Retrieves the bound value. |
Promise<V> |
rightShift(groovy.lang.Closure<V> closure) Schedule closure to be executed by pooled actor after data became available. |
protected void |
scheduleCallback(java.lang.Object attachment, MessageStream callback) Sends the result back to the actor, which is waiting asynchronously for the value to be bound. |
void |
separate(java.util.List<DataflowWriteChannel<?>> outputs, groovy.lang.Closure<java.util.List<java.lang.Object>> code) |
void |
separate(Pool pool, java.util.List<DataflowWriteChannel<?>> outputs, groovy.lang.Closure<java.util.List<java.lang.Object>> code) |
void |
separate(PGroup group, java.util.List<DataflowWriteChannel<?>> outputs, groovy.lang.Closure<java.util.List<java.lang.Object>> code) |
void |
separate(java.util.Map<java.lang.String, java.lang.Object> params, java.util.List<DataflowWriteChannel<?>> outputs, groovy.lang.Closure<java.util.List<java.lang.Object>> code) |
void |
separate(Pool pool, java.util.Map<java.lang.String, java.lang.Object> params, java.util.List<DataflowWriteChannel<?>> outputs, groovy.lang.Closure<java.util.List<java.lang.Object>> code) |
void |
separate(PGroup group, java.util.Map<java.lang.String, java.lang.Object> params, java.util.List<DataflowWriteChannel<?>> outputs, groovy.lang.Closure<java.util.List<java.lang.Object>> code) |
void |
setMetaClass(groovy.lang.MetaClass metaClass) |
void |
setProperty(java.lang.String propertyName, java.lang.Object newValue) |
void |
split(DataflowWriteChannel<T> target1, DataflowWriteChannel<T> target2) |
void |
split(Pool pool, DataflowWriteChannel<T> target1, DataflowWriteChannel<T> target2) |
void |
split(PGroup group, DataflowWriteChannel<T> target1, DataflowWriteChannel<T> target2) |
void |
split(java.util.List<DataflowWriteChannel<T>> targets) |
void |
split(Pool pool, java.util.List<DataflowWriteChannel<T>> targets) |
void |
split(PGroup group, java.util.List<DataflowWriteChannel<T>> targets) |
void |
split(java.util.Map<java.lang.String, java.lang.Object> params, DataflowWriteChannel<T> target1, DataflowWriteChannel<T> target2) |
void |
split(Pool pool, java.util.Map<java.lang.String, java.lang.Object> params, DataflowWriteChannel<T> target1, DataflowWriteChannel<T> target2) |
void |
split(PGroup group, java.util.Map<java.lang.String, java.lang.Object> params, DataflowWriteChannel<T> target1, DataflowWriteChannel<T> target2) |
void |
split(java.util.Map<java.lang.String, java.lang.Object> params, java.util.List<DataflowWriteChannel<T>> targets) |
void |
split(Pool pool, java.util.Map<java.lang.String, java.lang.Object> params, java.util.List<DataflowWriteChannel<T>> targets) |
void |
split(PGroup group, java.util.Map<java.lang.String, java.lang.Object> params, java.util.List<DataflowWriteChannel<T>> targets) |
protected void |
subscribe() A utility method to call at the very end of constructors of derived expressions. |
protected void |
subscribe(DataflowExpression.DataflowExpressionsCollector listener) |
DataflowReadChannel<T> |
tap(DataflowWriteChannel<T> target) |
DataflowReadChannel<T> |
tap(Pool pool, DataflowWriteChannel<T> target) |
DataflowReadChannel<T> |
tap(PGroup group, DataflowWriteChannel<T> target) |
DataflowReadChannel<T> |
tap(java.util.Map<java.lang.String, java.lang.Object> params, DataflowWriteChannel<T> target) |
DataflowReadChannel<T> |
tap(Pool pool, java.util.Map<java.lang.String, java.lang.Object> params, DataflowWriteChannel<T> target) |
DataflowReadChannel<T> |
tap(PGroup group, java.util.Map<java.lang.String, java.lang.Object> params, DataflowWriteChannel<T> target) |
Promise<V> |
then(groovy.lang.Closure<V> closure) Schedule closure to be executed after data became available. |
Promise<V> |
then(Pool pool, groovy.lang.Closure<V> closure) Schedule closure to be executed after data becomes available. |
Promise<V> |
then(PGroup group, groovy.lang.Closure<V> closure) Schedule closure to be executed after data becomes available. |
Promise<java.util.List> |
thenForkAndJoin(groovy.lang.Closure<? extends java.lang.Object>... closures) Schedule a set of closures to be executed after data became available on the current promise. |
Promise<java.util.List> |
thenForkAndJoin(Pool pool, groovy.lang.Closure<? extends java.lang.Object>... closures) Schedule a set of closures to be executed after data became available on the current promise. |
Promise<java.util.List> |
thenForkAndJoin(PGroup group, groovy.lang.Closure<? extends java.lang.Object>... closures) Schedule a set of closures to be executed after data became available on the current promise. |
java.lang.String |
toString() |
static DataflowExpression<V> |
transform(java.lang.Object another, groovy.lang.Closure closure) Transforms values bound eventually to dataflow variables using the supplied closure. |
void |
whenBound(groovy.lang.Closure<V> closure) Schedule closure to be executed by pooled actor after data becomes available. |
void |
whenBound(Pool pool, groovy.lang.Closure<V> closure) Schedule closure to be executed by pooled actor after data becomes available. |
void |
whenBound(PGroup group, groovy.lang.Closure<V> closure) Schedule closure to be executed by pooled actor after data becomes available. |
void |
whenBound(MessageStream stream) Send the bound data to provided stream when it becomes available |
void |
wheneverBound(groovy.lang.Closure<V> closure) Send all pieces of data bound in the future to the provided stream when it becomes available |
void |
wheneverBound(MessageStream stream) Send all pieces of data bound in the future to the provided stream when it becomes available. |
Methods inherited from class | Name |
---|---|
class WithSerialId |
createRemoteHandle, getOrCreateSerialHandle, getRemoteClass, writeReplace |
class java.lang.Object |
java.lang.Object#wait(), java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
Possible states
A request chain terminator
The current metaclass
Holds the current state of the variable
Updater for the state field
Holds the actual value. Is null before a concrete value is bound to it.
Points to the head of the chain of requests waiting for a value to be bound
Updater for the waiting field
Creates a new unbound Dataflow Expression
Assigns a value to the variable. Can only be invoked once on each instance of DataflowVariable. Allows attempts to bind to equal values.
value
- The value to assignAssigns a value to the variable. Returns silently if invoked on an already bound variable.
value
- The value to assignAssigns a value to the variable. Can only be invoked once on each instance of DataflowVariable Doesn't allow attempts to bind to equal values.
value
- The value to assignPerforms the actual bind operation, unblocks all blocked threads and informs all asynchronously waiting actors.
value
- The value to assignBinds the value after receiving a bing message over the wire
hostId
- Id of the bind originator hostmessage
- The value to bindEvaluates the expression after the ones we depend on are ready
Returns either standard property of the expression or creates an expression, which will request given property when the receiver becomes available
propertyName
- The name of the property to retrieveReads the value of the variable. Blocks, if the value has not been assigned yet.
Reads the value of the variable. Blocks up to given timeout, if the value has not been assigned yet.
timeout
- The timeout valueunits
- Units for the timeoutAsynchronously retrieves the value of the variable. Sends the actual value of the variable as a message back the the supplied actor once the value has been bound. The actor can perform other activities or release a thread back to the pool by calling react() waiting for the message with the value of the Dataflow Variable.
callback
- An actor to send the bound value to.Used by Dataflow operators. Asynchronously retrieves the value of the variable. Sends a message back the the supplied MessageStream with a map holding the supplied attachment under the 'attachment' key and the actual value of the variable under the 'result' key once the value has been bound. Attachment is an arbitrary value helping the actor.operator match its request with the reply. The actor/operator can perform other activities or release a thread back to the pool by calling react() waiting for the message with the value of the Dataflow Variable.
attachment
- arbitrary non-null attachment if reader needs better identification of resultcallback
- An actor to send the bound value plus the supplied index to.Invokes the method on itself or creates an expression, which will invoke the method n the bound value, once it is available.
Check if value has been set already for this expression
Blocks, if the value has not been assigned yet to the DataflowVariable
Blocks, if the value has not been assigned yet to the DataflowVariable
timeout
- The timeout valueunits
- Units for the timeoutSends notifications to all subscribers
hostId
- The local host idRetrieves the bound value. Returns null, if no value is available.
Schedule closure to be executed by pooled actor after data became available. It is important to notice that even if the expression is already bound the execution of closure will not happen immediately but will be scheduled
closure
- closure to execute when data becomes available. The closure should take at most one argument.Sends the result back to the actor, which is waiting asynchronously for the value to be bound. The message will either be a map holding the attachment under the 'attachment' key and the actual bound value under the 'result' key, or it will be the result itself if the callback doesn't care about the index.
attachment
- An arbitrary object identifying the requestcallback
- The actor to send the message toA utility method to call at the very end of constructors of derived expressions. Creates and subscribes a listener to monitor the expression
Schedule closure to be executed after data became available. It is important to notice that even if the expression is already bound the execution of closure will not happen immediately but will be scheduled
closure
- closure to execute when data becomes available. The closure should take at most one argument.Schedule closure to be executed after data becomes available. It is important to notice that even if the expression is already bound the execution of closure will not happen immediately but will be scheduled.
pool
- The thread pool to use for task scheduling for asynchronous message deliveryclosure
- closure to execute when data becomes available. The closure should take at most one argument.Schedule closure to be executed after data becomes available. It is important to notice that even if the expression is already bound the execution of closure will not happen immediately but will be scheduled.
group
- The PGroup to use for task scheduling for asynchronous message deliveryclosure
- closure to execute when data becomes available. The closure should take at most one argument.Schedule a set of closures to be executed after data became available on the current promise. It is important to notice that even if the expression is already bound the execution of closures will not happen immediately, but will be scheduled. The returned Promise will hold a list of results of the individual closures, ordered in the same order. In case of an exception being thrown from any of the closures, the first exception gets propagated into the promise returned from the method.
closures
- closure to execute when data becomes available. The closure should take at most one argument.Schedule a set of closures to be executed after data became available on the current promise. It is important to notice that even if the expression is already bound the execution of closures will not happen immediately, but will be scheduled. The returned Promise will hold a list of results of the individual closures, ordered in the same order. In case of an exception being thrown from any of the closures, the first exception gets propagated into the promise returned from the method.
pool
- The thread pool to use for task scheduling for asynchronous message deliveryclosures
- closure to execute when data becomes available. The closure should take at most one argument.Schedule a set of closures to be executed after data became available on the current promise. It is important to notice that even if the expression is already bound the execution of closures will not happen immediately, but will be scheduled. The returned Promise will hold a list of results of the individual closures, ordered in the same order. In case of an exception being thrown from any of the closures, the first exception gets propagated into the promise returned from the method.
group
- The PGroup to use for task scheduling for asynchronous message deliveryclosures
- closure to execute when data becomes available. The closure should take at most one argument.Transforms values bound eventually to dataflow variables using the supplied closure.
another
- A list of DataflowVariables to transformclosure
- The transformation function, which must take the same number of arguments as there are elements in the "another" list
- Type of the bound valuesSchedule closure to be executed by pooled actor after data becomes available. It is important to notice that even if the expression is already bound the execution of closure will not happen immediately but will be scheduled.
closure
- closure to execute when data becomes available. The closure should take at most one argument.Schedule closure to be executed by pooled actor after data becomes available. It is important to notice that even if the expression is already bound the execution of closure will not happen immediately but will be scheduled.
pool
- The thread pool to use for task scheduling for asynchronous message deliveryclosure
- closure to execute when data becomes available. The closure should take at most one argument.Schedule closure to be executed by pooled actor after data becomes available. It is important to notice that even if the expression is already bound the execution of closure will not happen immediately but will be scheduled.
group
- The PGroup to use for task scheduling for asynchronous message deliveryclosure
- closure to execute when data becomes available. The closure should take at most one argument.Send the bound data to provided stream when it becomes available
stream
- stream where to send resultSend all pieces of data bound in the future to the provided stream when it becomes available. *
closure
- closure to execute when data becomes available. The closure should take at most one argument.Send all pieces of data bound in the future to the provided stream when it becomes available.
stream
- stream where to send resultCopyright © 2008–2014 Václav Pech. All Rights Reserved.