|
org.codehaus.gpars | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgroovyx.gpars.serial.WithSerialId
groovyx.gpars.dataflow.expression.DataflowExpression
groovyx.gpars.dataflow.DataflowVariable
groovyx.gpars.dataflow.SyncDataflowVariable
public final class SyncDataflowVariable extends DataflowVariable
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.
Field Summary | |
---|---|
private static java.lang.String |
ERROR_READING_A_SYNCHRONOUS_CHANNEL
|
private ResizeableCountDownLatch |
parties
|
Fields inherited from class DataflowVariable | |
---|---|
serialVersionUID |
Fields inherited from class DataflowExpression | |
---|---|
ATTACHMENT, RESULT, S_INITIALIZED, S_INITIALIZING, S_NOT_INITIALIZED, dummyWaitingThread, metaClass, serialVersionUID, state, value, waiting |
Fields inherited from class WithSerialId | |
---|---|
serialHandle, serialVersionUID |
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 | |
---|---|
private void
|
awaitParties()
|
boolean
|
awaitingParties()
Reports whether the variable is still waiting for parties to arrive for the rendezvous. |
DataflowReadChannel
|
chainWith(PGroup group, groovy.lang.Closure closure)
|
void
|
decrementParties()
Decreases the number of parties required to perform data exchange by one |
protected void
|
doBindImpl(java.lang.Object value)
|
java.lang.Object
|
getVal()
Reads the value of the variable. |
java.lang.Object
|
getVal(long timeout, java.util.concurrent.TimeUnit units)
Reads the value of the variable. |
void
|
incrementParties()
Increases the number of parties required to perform data exchange by one. |
DataflowReadChannel
|
merge(PGroup group, java.util.List others, groovy.lang.Closure closure)
|
private void
|
readerIsReady()
|
private boolean
|
readerIsReady(long timeout)
|
protected void
|
scheduleCallback(java.lang.Object attachment, MessageStream callback)
|
boolean
|
shouldThrowTimeout()
|
DataflowReadChannel
|
tap(PGroup group, DataflowWriteChannel target)
|
Methods inherited from class DataflowVariable | |
---|---|
bindDFV, get, get, getRemoteClass, leftShift, leftShift, shouldThrowTimeout |
Methods inherited from class DataflowExpression | |
---|---|
DataflowExpression, binaryChoice, binaryChoice, binaryChoice, bind, bindSafely, bindUnique, chainWith, chainWith, chainWith, choice, choice, choice, doBind, doBindImpl, doBindRemote, evaluate, filter, filter, filter, getMetaClass, getProperty, getVal, getVal, getValAsync, getValAsync, handleInterruption, into, into, into, invokeMethod, isBound, join, join, length, merge, merge, merge, merge, merge, merge, notifyRemote, or, or, poll, rightShift, scheduleCallback, separate, separate, separate, setMetaClass, setProperty, split, split, split, split, split, split, subscribe, subscribe, tap, tap, tap, then, then, then, toString, transform, whenBound, whenBound, whenBound, whenBound, wheneverBound, wheneverBound |
Methods inherited from class WithSerialId | |
---|---|
createRemoteHandle, getOrCreateSerialHandle, getRemoteClass, writeReplace |
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 transferred
Method Detail |
---|
private void awaitParties()
public boolean awaitingParties()
@Override public DataflowReadChannel chainWith(PGroup group, groovy.lang.Closure closure)
public void decrementParties()
@Override protected void doBindImpl(java.lang.Object value)
@Override public java.lang.Object getVal()
@Override public java.lang.Object getVal(long timeout, java.util.concurrent.TimeUnit units)
timeout
- The timeout valueunits
- Units for the timeout
public void incrementParties()
@Override public DataflowReadChannel merge(PGroup group, java.util.List others, groovy.lang.Closure closure)
private void readerIsReady()
private boolean readerIsReady(long timeout)
@Override protected void scheduleCallback(java.lang.Object attachment, MessageStream callback)
@Override boolean shouldThrowTimeout()
@Override public DataflowReadChannel tap(PGroup group, DataflowWriteChannel target)
Copyright © 2008–2012 Václav Pech. All Rights Reserved.