|
org.codehaus.gpars | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object groovyx.gpars.serial.WithSerialId groovyx.gpars.dataflow.DataflowExpression
@SuppressWarnings({"UnqualifiedStaticUsage", "CallToSimpleGetterFromWithinClass", "ConstantDeclaredInAbstractClass"}) public abstract class DataflowExpression extends WithSerialId
The base class for all dataflow elements.
Nested Class Summary | |
---|---|
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 from |
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. |
Field Summary | |
---|---|
private static java.lang.String |
ATTACHMENT
|
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 |
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 |
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 |
waitingUpdater
Updater for the waiting field |
Fields inherited from class WithSerialId | |
---|---|
serialHandle, serialVersionUID |
Constructor Summary | |
DataflowExpression()
|
Method Summary | |
---|---|
protected java.lang.Object
|
DataflowExpression()
Creates a new unbound Dataflow Expression |
void
|
bind(T value)
Assigns a value to the variable. |
void
|
bindSafely(T value)
Assigns a value to the variable. |
void
|
bindUnique(T value)
Assigns a value to the variable. |
private void
|
doBind(T value)
Performs the actual bind operation, unblocks all blocked threads and informs all asynchronously waiting actors. |
private void
|
doBindImpl(T value)
|
void
|
doBindRemote(java.util.UUID hostId, T message)
Binds the value after receiving a bing message over the wire |
protected T
|
evaluate()
Evaluate expression after the ones we depend on are ready |
groovy.lang.MetaClass
|
getMetaClass()
|
java.lang.Object
|
getProperty(java.lang.String propertyName)
Returns either standard property of expression or creates expression, which will request given property when receiver became 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)
|
java.lang.Object
|
invokeMethod(java.lang.String name, java.lang.Object args)
|
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 |
private void
|
notifyRemote(java.util.UUID hostId)
Sends notifications to all subscribers |
DataflowExpression
|
poll()
Retrieves the bound value. |
void
|
rightShift(groovy.lang.Closure closure)
Schedule closure to be executed by pooled actor after data became available It is important to notice that even if data already available the execution of closure will not happen immediately but will be scheduled |
private 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
|
setMetaClass(groovy.lang.MetaClass metaClass)
|
void
|
setProperty(java.lang.String propertyName, java.lang.Object newValue)
|
protected void
|
subscribe()
Utility method to call at the very end of constructor of derived expressions. |
protected void
|
subscribe(DataflowExpression.DataflowExpressionsCollector listener)
|
java.lang.String
|
toString()
|
static DataflowExpression
|
transform(java.lang.Object another, groovy.lang.Closure closure)
|
void
|
whenBound(groovy.lang.Closure closure)
Schedule closure to be executed by pooled actor after data becomes available It is important to notice that even if data already available the execution of closure will not happen immediately but will be scheduled. |
void
|
whenBound(Pool pool, groovy.lang.Closure closure)
Schedule closure to be executed by pooled actor after data becomes available It is important to notice that even if data already available the execution of closure will not happen immediately but will be scheduled. |
void
|
whenBound(PGroup group, groovy.lang.Closure closure)
Schedule closure to be executed by pooled actor after data becomes available It is important to notice that even if data already available the execution of closure will not happen immediately but will be scheduled. |
void
|
whenBound(MessageStream stream)
Send the bound data to provided stream when it becomes available |
void
|
wheneverBound(groovy.lang.Closure 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 WithSerialId | |
---|---|
createRemoteHandle, getOrCreateSerialHandle, getRemoteClass, writeReplace |
Methods inherited from class java.lang.Object | |
---|---|
java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#wait(long, int), 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() |
Field Detail |
---|
private static final java.lang.String ATTACHMENT
private static final java.lang.String RESULT
protected static final int S_INITIALIZED
protected static final int S_INITIALIZING
protected static final int S_NOT_INITIALIZED
private static final DataflowExpression.WaitingThread dummyWaitingThread
private groovy.lang.MetaClass metaClass
private static final long serialVersionUID
protected int state
@SuppressWarnings({"rawtypes", "RawUseOfParameterizedType"}) protected static final java.util.concurrent.atomic.AtomicIntegerFieldUpdater stateUpdater
@SuppressWarnings({"InstanceVariableMayNotBeInitialized"}) protected T value
@SuppressWarnings({"UnusedDeclaration"}) //modified through stateUpdater private DataflowExpression.WaitingThread waiting
@SuppressWarnings({"rawtypes", "RawUseOfParameterizedType"}) protected static final java.util.concurrent.atomic.AtomicReferenceFieldUpdater waitingUpdater
Constructor Detail |
---|
DataflowExpression()
Method Detail |
---|
protected java.lang.Object DataflowExpression()
public final void bind(T value)
value
- The value to assign
public final void bindSafely(T value)
value
- The value to assign
public final void bindUnique(T value)
value
- The value to assign
private void doBind(T value)
value
- The value to assign
private void doBindImpl(T value)
public final void doBindRemote(java.util.UUID hostId, T message)
hostId
- Id of the bind originator hostmessage
- The value to bind
protected T evaluate()
@Override public final groovy.lang.MetaClass getMetaClass()
@Override public final java.lang.Object getProperty(java.lang.String propertyName)
propertyName
- The name of the property to retrieve
@Override public final T getVal()
@Override public final T getVal(long timeout, java.util.concurrent.TimeUnit units)
timeout
- The timeout valueunits
- Units for the timeout
@Override public final void getValAsync(MessageStream callback)
callback
- An actor to send the bound value to.
@Override public final void getValAsync(java.lang.Object attachment, MessageStream callback)
attachment
- arbitrary non-null attachment if reader needs better identification of resultcallback
- An actor to send the bound value plus the supplied index to.
private static void handleInterruption(java.util.concurrent.atomic.AtomicBoolean newWaiting)
@Override public final java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args)
@Override public final boolean isBound()
public final void join()
public final void join(long timeout, java.util.concurrent.TimeUnit units)
timeout
- The timeout valueunits
- Units for the timeout
private void notifyRemote(java.util.UUID hostId)
hostId
- The local host id
@Override public final DataflowExpression poll()
@Override public final void rightShift(groovy.lang.Closure closure)
closure
- closure to execute when data available
@SuppressWarnings({"TypeMayBeWeakened"}) private void scheduleCallback(java.lang.Object attachment, MessageStream callback)
attachment
- An arbitrary object identifying the requestcallback
- The actor to send the message to
@Override public final void setMetaClass(groovy.lang.MetaClass metaClass)
@Override public final void setProperty(java.lang.String propertyName, java.lang.Object newValue)
protected final void subscribe()
protected void subscribe(DataflowExpression.DataflowExpressionsCollector listener)
@SuppressWarnings({"ArithmeticOnVolatileField"}) @Override public java.lang.String toString()
public static DataflowExpression transform(java.lang.Object another, groovy.lang.Closure closure)
@Override public final void whenBound(groovy.lang.Closure closure)
closure
- closure to execute when data available
@Override public void whenBound(Pool pool, groovy.lang.Closure closure)
pool
- The thread pool to use for task scheduling for asynchronous message deliveryclosure
- closure to execute when data available
@Override public final void whenBound(PGroup group, groovy.lang.Closure closure)
group
- The PGroup to use for task scheduling for asynchronous message deliveryclosure
- closure to execute when data available
@Override public final void whenBound(MessageStream stream)
stream
- stream where to send result
@Override public final void wheneverBound(groovy.lang.Closure closure)
closure
- closure to execute when data available
@Override public final void wheneverBound(MessageStream stream)
stream
- stream where to send result
Copyright © 2008–2010 Václav Pech. All Rights Reserved.