|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object groovyx.gpars.serial.WithSerialId groovyx.gpars.dataflow.DataflowExpression<T>
public abstract class DataflowExpression<T>
The base class for all dataflow elements.
Nested Class Summary | |
---|---|
static class |
DataflowExpression.BindDataflow<T>
Represents a remote message binding a value to a remoted DataflowExpression |
(package private) class |
DataflowExpression.DataflowExpressionsCollector
Listener for availability of data flow expressions we depend from |
private static class |
DataflowExpression.TransformMany<V>
|
private static class |
DataflowExpression.TransformOne<V>
|
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 DataflowExpression.WaitingThread |
dummyWaitingThread
A request chain terminator |
private groovy.lang.MetaClass |
metaClass
The current metaclass |
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 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,DataflowExpression.WaitingThread> |
waitingUpdater
Updater for the waiting field |
Fields inherited from class groovyx.gpars.serial.WithSerialId |
---|
serialHandle |
Constructor Summary | |
---|---|
protected |
DataflowExpression()
Creates a new unbound Dataflow Expression |
Method Summary | ||
---|---|---|
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<T> |
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 |
|
void |
setMetaClass(groovy.lang.MetaClass metaClass)
|
|
void |
setProperty(java.lang.String propertyName,
java.lang.Object newValue)
|
|
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. |
|
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
|
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(MessageStream stream)
Send the bound data to provided stream when it becomes available |
|
void |
whenBound(groovyx.gpars.group.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(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 |
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 groovyx.gpars.serial.WithSerialId |
---|
createRemoteHandle, getOrCreateSerialHandle, getRemoteClass, writeReplace |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private static final java.lang.String ATTACHMENT
private static final java.lang.String RESULT
protected static final java.util.concurrent.atomic.AtomicIntegerFieldUpdater<DataflowExpression> stateUpdater
protected static final java.util.concurrent.atomic.AtomicReferenceFieldUpdater<DataflowExpression,DataflowExpression.WaitingThread> waitingUpdater
private static final long serialVersionUID
private groovy.lang.MetaClass metaClass
protected volatile T value
protected volatile int state
private volatile DataflowExpression.WaitingThread waiting
protected static final int S_NOT_INITIALIZED
protected static final int S_INITIALIZING
protected static final int S_INITIALIZED
private static final DataflowExpression.WaitingThread dummyWaitingThread
Constructor Detail |
---|
protected DataflowExpression()
Method Detail |
---|
public final boolean isBound()
isBound
in interface DataflowReadChannel<T>
public final void getValAsync(MessageStream callback)
getValAsync
in interface DataflowReadChannel<T>
callback
- An actor to send the bound value to.public final void getValAsync(java.lang.Object attachment, MessageStream callback)
getValAsync
in interface DataflowReadChannel<T>
attachment
- arbitrary non-null attachment if reader needs better identification of resultcallback
- An actor to send the bound value plus the supplied index to.public final void join() throws java.lang.InterruptedException
java.lang.InterruptedException
- If the current thread gets interrupted while waiting for the variable to be boundpublic final void join(long timeout, java.util.concurrent.TimeUnit units) throws java.lang.InterruptedException
timeout
- The timeout valueunits
- Units for the timeout
java.lang.InterruptedException
- If the current thread gets interrupted while waiting for the variable to be boundpublic final T getVal() throws java.lang.InterruptedException
getVal
in interface DataflowReadChannel<T>
java.lang.InterruptedException
- If the current thread gets interrupted while waiting for the variable to be boundpublic final T getVal(long timeout, java.util.concurrent.TimeUnit units) throws java.lang.InterruptedException
getVal
in interface DataflowReadChannel<T>
timeout
- The timeout valueunits
- Units for the timeout
java.lang.InterruptedException
- If the current thread gets interrupted while waiting for the variable to be boundpublic final DataflowExpression<T> poll()
poll
in interface DataflowReadChannel<T>
java.lang.InterruptedException
- If the current thread is interruptedprivate static void handleInterruption(java.util.concurrent.atomic.AtomicBoolean newWaiting) throws java.lang.InterruptedException
java.lang.InterruptedException
public final void bindSafely(T value)
value
- The value to assignpublic final void bind(T value)
value
- The value to assignpublic final void bindUnique(T value)
value
- The value to assignprivate void doBind(T value)
value
- The value to assignprivate void doBindImpl(T value)
public final void doBindRemote(java.util.UUID hostId, T message)
hostId
- Id of the bind originator hostmessage
- The value to bindprivate void notifyRemote(java.util.UUID hostId)
hostId
- The local host idprivate void scheduleCallback(java.lang.Object attachment, MessageStream callback)
attachment
- An arbitrary object identifying the requestcallback
- The actor to send the message topublic final void rightShift(groovy.lang.Closure closure)
rightShift
in interface DataflowReadChannel<T>
closure
- closure to execute when data availablepublic final void whenBound(groovy.lang.Closure closure)
whenBound
in interface DataflowReadChannel<T>
closure
- closure to execute when data availablepublic void whenBound(Pool pool, groovy.lang.Closure closure)
whenBound
in interface DataflowReadChannel<T>
pool
- The thread pool to use for task scheduling for asynchronous message deliveryclosure
- closure to execute when data availablepublic final void whenBound(groovyx.gpars.group.PGroup group, groovy.lang.Closure closure)
whenBound
in interface DataflowReadChannel<T>
group
- The PGroup to use for task scheduling for asynchronous message deliveryclosure
- closure to execute when data availablepublic final void whenBound(MessageStream stream)
whenBound
in interface DataflowReadChannel<T>
stream
- stream where to send resultpublic final void wheneverBound(groovy.lang.Closure closure)
wheneverBound
in interface DataflowReadChannel<T>
closure
- closure to execute when data availablepublic final void wheneverBound(MessageStream stream)
wheneverBound
in interface DataflowReadChannel<T>
stream
- stream where to send resultpublic static <V> DataflowExpression<V> transform(java.lang.Object another, groovy.lang.Closure closure)
protected final void subscribe()
protected T evaluate()
protected void subscribe(DataflowExpression.DataflowExpressionsCollector listener)
public final java.lang.Object invokeMethod(java.lang.String name, java.lang.Object args)
invokeMethod
in interface groovy.lang.GroovyObject
public final java.lang.Object getProperty(java.lang.String propertyName)
getProperty
in interface groovy.lang.GroovyObject
propertyName
- The name of the property to retrieve
public final void setMetaClass(groovy.lang.MetaClass metaClass)
setMetaClass
in interface groovy.lang.GroovyObject
public final void setProperty(java.lang.String propertyName, java.lang.Object newValue)
setProperty
in interface groovy.lang.GroovyObject
public final groovy.lang.MetaClass getMetaClass()
getMetaClass
in interface groovy.lang.GroovyObject
public java.lang.String toString()
toString
in class java.lang.Object
|
Copyright © 2008–2010 Václav Pech. All Rights Reserved. | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |