org.codehaus.gpars

groovyx.gpars.dataflow
[Java] Class SyncDataflowVariable

java.lang.Object
  groovyx.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.

Authors:
Vaclav Pech


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, A_DATAFLOW_VARIABLE_CAN_ONLY_BE_ASSIGNED_ONCE_ONLY_RE_ASSIGNMENTS_TO_AN_EQUAL_VALUE_ARE_ALLOWED, CANNOT_FIRE_BIND_ERRORS_THE_THREAD_HAS_BEEN_INTERRUPTED, RESULT, S_INITIALIZED, S_INITIALIZING, S_NOT_INITIALIZED, dummyWaitingThread, error, eventManager, metaClass, serialVersionUID, state, value, waiting
 
Fields inherited from class WithSerialId
serialHandle, serialVersionUID
 
Constructor Summary
SyncDataflowVariable()

SyncDataflowVariable(int parties)

 
Method Summary
private void awaitParties()

boolean awaitingParties()

DataflowReadChannel chainWith(PGroup group, groovy.lang.Closure closure)

void decrementParties()

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)

void incrementParties()

Decreases 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)

Increases the number of parties required to perform data exchange by one.

protected void scheduleCallback(java.lang.Object attachment, MessageStream callback)

boolean shouldThrowTimeout()

Reports whether the variable is still waiting for parties to arrive for the rendezvous.

DataflowReadChannel tap(PGroup group, DataflowWriteChannel target)

 
Methods inherited from class DataflowVariable
bindDFV, get, get, getError, getRemoteClass, isError, leftShift, leftShift, shouldThrowTimeout, then, then, then, touch
 
Methods inherited from class DataflowExpression
DataflowExpression, binaryChoice, binaryChoice, binaryChoice, binaryChoice, binaryChoice, binaryChoice, bind, bindError, bindSafely, bindUnique, chainWith, chainWith, chainWith, chainWith, chainWith, chainWith, choice, choice, choice, choice, choice, choice, createEventManager, doBind, doBindImpl, doBindRemote, doThenForkAndJoin, evaluate, filter, filter, filter, filter, filter, filter, fireBindError, fireBindError, fireOnMessage, getBindErrorManager, getEventManager, getMetaClass, getProperty, getVal, getVal, getValAsync, getValAsync, handleInterruption, into, into, into, into, into, into, invokeMethod, isBound, join, join, length, merge, merge, merge, merge, merge, merge, merge, merge, merge, merge, merge, merge, notifyRemote, or, or, poll, rightShift, scheduleCallback, 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, tap, then, then, then, thenForkAndJoin, thenForkAndJoin, thenForkAndJoin, toString, transform, whenBound, whenBound, whenBound, whenBound, wheneverBound, wheneverBound
 
Methods inherited from class WithSerialId
createRemoteHandle, getOrCreateSerialHandle, getRemoteClass, writeReplace
 

Field Detail

ERROR_READING_A_SYNCHRONOUS_CHANNEL

private static final java.lang.String ERROR_READING_A_SYNCHRONOUS_CHANNEL


parties

private final ResizeableCountDownLatch parties


 
Constructor Detail

SyncDataflowVariable

public SyncDataflowVariable()


SyncDataflowVariable

public SyncDataflowVariable(int parties)


 
Method Detail

awaitParties

private void awaitParties()


awaitingParties

public boolean awaitingParties()


chainWith

@java.lang.Overridepublic  DataflowReadChannel merge(final PGroup group, final List> others, final Closure closure) {
public DataflowReadChannel chainWith(PGroup group, groovy.lang.Closure closure)


decrementParties

public void decrementParties()


doBindImpl

@java.lang.OverridereaderIsReady();
protected void doBindImpl(java.lang.Object value)


getVal

@java.lang.Override
public java.lang.Object getVal()
Reads the value of the variable. Blocks up to given timeout, if the value has not been assigned yet.
throws:
InterruptedException If the current thread gets interrupted while waiting for the variable to be bound
Parameters:
timeout - The timeout value
units - Units for the timeout
Returns:
The actual value


getVal

@java.lang.Override
public java.lang.Object getVal(long timeout, java.util.concurrent.TimeUnit units)


incrementParties

public void incrementParties()
Decreases the number of parties required to perform data exchange by one


merge

@java.lang.OverridereaderIsReady();
public DataflowReadChannel merge(PGroup group, java.util.List others, groovy.lang.Closure closure)


readerIsReady

private void readerIsReady()


readerIsReady

private boolean readerIsReady(long timeout)
Increases the number of parties required to perform data exchange by one.


scheduleCallback

@java.lang.Override
protected void scheduleCallback(java.lang.Object attachment, MessageStream callback)


shouldThrowTimeout

@java.lang.Overridepublic  DataflowReadChannel chainWith(final PGroup group, final Closure closure) {
boolean shouldThrowTimeout()
Reports whether the variable is still waiting for parties to arrive for the rendezvous.
Returns:
True if not all parties have shown yet


tap

@java.lang.Override}
public DataflowReadChannel tap(PGroup group, DataflowWriteChannel target)


 

Copyright © 2008–2013 Václav Pech. All Rights Reserved.