|
||||||||||
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.expression.DataflowExpression<T> groovyx.gpars.dataflow.DataflowVariable<T> groovyx.gpars.dataflow.SyncDataflowVariable<T>
public final class SyncDataflowVariable<T>
A synchronous variant of DataflowVariable, which blocks the writer as well as the readers. The synchronous variable ensures a specified number of readers must ask for a value before the writer as well as the readers can continue.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class groovyx.gpars.dataflow.DataflowVariable |
---|
DataflowVariable.RemoteDataflowVariable<T> |
Nested classes/interfaces inherited from class groovyx.gpars.dataflow.expression.DataflowExpression |
---|
DataflowExpression.BindDataflow<T> |
Field Summary | |
---|---|
private static java.lang.String |
ERROR_READING_A_SYNCHRONOUS_CHANNEL
|
private ResizeableCountDownLatch |
parties
|
Fields inherited from class groovyx.gpars.dataflow.expression.DataflowExpression |
---|
error, S_INITIALIZED, S_INITIALIZING, S_NOT_INITIALIZED, state, value |
Fields inherited from class groovyx.gpars.serial.WithSerialId |
---|
serialHandle |
Constructor Summary | |
---|---|
SyncDataflowVariable()
Creates a new variable, which will never block writers. |
|
SyncDataflowVariable(int parties)
Creates a new variable blocking the specified number of readers. |
Method Summary | ||
---|---|---|
boolean |
awaitingParties()
Reports whether the variable is still waiting for parties to arrive for the rendezvous. |
|
private void |
awaitParties()
|
|
void |
decrementParties()
Decreases the number of parties required to perform data exchange by one |
|
protected void |
doBindImpl(T value)
|
|
T |
getVal()
Reads the value of the variable. |
|
T |
getVal(long timeout,
java.util.concurrent.TimeUnit units)
Reads the value of the variable. |
|
|
chainWith(PGroup group,
groovy.lang.Closure<V> closure)
Creates and attaches a new operator processing values from the channel |
|
void |
incrementParties()
Increases the number of parties required to perform data exchange by one. |
|
|
merge(PGroup group,
java.util.List<DataflowReadChannel<java.lang.Object>> others,
groovy.lang.Closure<V> closure)
Merges channels together as inputs for a single dataflow operator. |
|
private void |
readerIsReady()
|
|
private boolean |
readerIsReady(long timeout)
|
|
(package private) boolean |
shouldThrowTimeout()
|
|
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. |
|
DataflowReadChannel<T> |
tap(PGroup group,
DataflowWriteChannel<T> target)
Taps into the pipeline. |
Methods inherited from class groovyx.gpars.dataflow.DataflowVariable |
---|
get, get, getError, getRemoteClass, isError, leftShift, leftShift, then, then, then |
Methods inherited from class groovyx.gpars.dataflow.expression.DataflowExpression |
---|
binaryChoice, binaryChoice, binaryChoice, binaryChoice, binaryChoice, binaryChoice, bind, bindError, bindSafely, bindUnique, doBindRemote, evaluate, filter, filter, filter, filter, filter, filter, getEventManager, getMetaClass, getProperty, getValAsync, getValAsync, chainWith, chainWith, chainWith, chainWith, chainWith, choice, choice, choice, choice, choice, choice, into, into, into, into, into, into, invokeMethod, isBound, join, join, length, merge, merge, merge, merge, merge, merge, merge, merge, merge, merge, merge, or, or, poll, rightShift, separate, separate, separate, separate, separate, separate, setMetaClass, setProperty, split, split, split, split, split, split, split, split, split, split, split, split, subscribe, subscribe, tap, tap, tap, tap, tap, then, then, then, toString, transform, whenBound, whenBound, whenBound, whenBound, wheneverBound, wheneverBound |
Methods inherited from class groovyx.gpars.serial.WithSerialId |
---|
createRemoteHandle, getOrCreateSerialHandle, writeReplace |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface groovyx.gpars.dataflow.DataflowReadChannel |
---|
binaryChoice, binaryChoice, binaryChoice, binaryChoice, binaryChoice, binaryChoice, filter, filter, filter, filter, filter, filter, getEventManager, getValAsync, getValAsync, chainWith, chainWith, chainWith, chainWith, chainWith, choice, choice, choice, choice, choice, choice, into, into, into, into, into, into, isBound, length, merge, merge, merge, merge, merge, merge, merge, merge, merge, merge, merge, or, or, poll, rightShift, separate, separate, separate, separate, separate, separate, split, split, split, split, split, split, split, split, split, split, split, split, tap, tap, tap, tap, tap, then, then, then, whenBound, whenBound, whenBound, whenBound, wheneverBound, wheneverBound |
Methods inherited from interface groovyx.gpars.dataflow.DataflowWriteChannel |
---|
bind |
Methods inherited from interface groovyx.gpars.dataflow.Promise |
---|
isBound, join, join, rightShift, then, then, then, whenBound, whenBound, whenBound, whenBound |
Field Detail |
---|
private static final java.lang.String ERROR_READING_A_SYNCHRONOUS_CHANNEL
private final ResizeableCountDownLatch parties
Constructor Detail |
---|
public SyncDataflowVariable()
public SyncDataflowVariable(int parties)
parties
- Number of readers that have to match a writer before the message gets transferredMethod Detail |
---|
protected void doBindImpl(T value)
doBindImpl
in class DataflowExpression<T>
public T getVal() throws java.lang.InterruptedException
getVal
in interface DataflowReadChannel<T>
getVal
in class DataflowExpression<T>
java.lang.InterruptedException
- If the current thread gets interrupted while waiting for the variable to be boundpublic T getVal(long timeout, java.util.concurrent.TimeUnit units) throws java.lang.InterruptedException
getVal
in interface DataflowReadChannel<T>
getVal
in class DataflowExpression<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 boundboolean shouldThrowTimeout()
shouldThrowTimeout
in class DataflowVariable<T>
public boolean awaitingParties()
public <V> DataflowReadChannel<V> chainWith(PGroup group, groovy.lang.Closure<V> closure)
DataflowReadChannel
chainWith
in interface DataflowReadChannel<T>
chainWith
in class DataflowExpression<T>
V
- The type of values returned from the supplied closuregroup
- The PGroup to useclosure
- The function to invoke on all incoming values as part of the new operator's body
public DataflowReadChannel<T> tap(PGroup group, DataflowWriteChannel<T> target)
DataflowReadChannel
tap
in interface DataflowReadChannel<T>
tap
in class DataflowExpression<T>
group
- The PGroup to usetarget
- The channel to tap data into
public <V> DataflowReadChannel<V> merge(PGroup group, java.util.List<DataflowReadChannel<java.lang.Object>> others, groovy.lang.Closure<V> closure)
DataflowReadChannel
merge
in interface DataflowReadChannel<T>
merge
in class DataflowExpression<T>
V
- The type of values passed between the channelsgroup
- The PGroup to useothers
- The channels to merge withclosure
- The function to invoke on all incoming values as part of the new operator's body. The number of arguments to the closure must match the number of input channels.
protected void scheduleCallback(java.lang.Object attachment, MessageStream callback)
DataflowExpression
scheduleCallback
in class DataflowExpression<T>
attachment
- An arbitrary object identifying the requestcallback
- The actor to send the message toprivate void readerIsReady()
private void awaitParties()
private boolean readerIsReady(long timeout)
public void incrementParties()
public void decrementParties()
|
Copyright © 2008–2012 Václav Pech. All Rights Reserved. | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |