|
Groovy Documentation | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgpars.dataflow.DataFlowStream
@SuppressWarnings({"LawOfDemeter", "MethodReturnOfConcreteClass", "AnonymousInnerClass", "AnonymousInnerClassWithTooManyMethods"}) public final class DataFlowStream
Represents a thread-safe data flow stream. Values or DataFlowVariables are added using the '<<' operator and safely read once available using the 'val' property. The iterative methods like each(), collect(), iterator(), any(), all() or the for loops work with snapshots of the stream at the time of calling the particular method. For actors and Dataflow Operators the asynchronous non-blocking variants of the getValAsync() methods can be used. They register the request to read a value and will send a message to the actor or operator once the value is available.
Method Summary | |
---|---|
Object
|
getVal()
Retrieves the value at the head of the buffer. |
void
|
getValAsync(MessageStream messageStream)
Asynchronously retrieves the value at the head of the buffer. |
void
|
getValAsync(Object attachment, MessageStream messageStream)
Asynchronously retrieves the value at the head of the buffer. |
Iterator
|
iterator()
Returns an iterator over a current snapshot of the buffer's content. |
void
|
leftShift(DataFlowExpression ref)
Adds a DataFlowVariable to the buffer. |
void
|
leftShift(Object value)
Adds a DataFlowVariable representing the passed in value to the buffer. |
int
|
length()
Returns the current size of the buffer |
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 |
String
|
toString()
|
void
|
whenBound(groovy.lang.Closure closure)
Schedule closure to be executed by pooled actor each time 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 all pieces of data bound in the future to the provided stream when it becomes available |
void
|
whenNextBound(groovy.lang.Closure closure)
Schedule closure to be executed by pooled actor after the next 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
|
whenNextBound(MessageStream stream)
Send the next bound piece of data to the provided stream when it becomes available |
Methods inherited from class Object | |
---|---|
wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll |
Method Detail |
---|
public Object getVal()
public void getValAsync(MessageStream messageStream)
messageStream
- The actor to notify when a value is bound
public void getValAsync(Object attachment, MessageStream messageStream)
attachment
- An arbitrary value to identify operator channels and so match requests and repliesmessageStream
- The actor / operator to notify when a value is bound
public Iterator iterator()
@SuppressWarnings("unchecked") public void leftShift(DataFlowExpression ref)
ref
- The DFV to add to the stream
public void leftShift(Object value)
value
- The value to bind to the head of the stream
public int length()
public void rightShift(groovy.lang.Closure closure)
closure
- closure to execute when data available
@Override public String toString()
public void whenBound(groovy.lang.Closure closure)
closure
- closure to execute when data available
public void whenBound(MessageStream stream)
stream
- stream where to send result
public void whenNextBound(groovy.lang.Closure closure)
closure
- closure to execute when data available
public void whenNextBound(MessageStream stream)
stream
- stream where to send result
Groovy Documentation