|
org.codehaus.gpars | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object groovyx.gpars.dataflow.DataflowQueue
@java.lang.SuppressWarnings*/ public class DataflowQueue
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.
Field Summary | |
---|---|
private DataflowChannelEventOrchestrator |
eventManager
|
private java.util.concurrent.LinkedBlockingQueue |
queue
|
private java.lang.Object |
queueLock
A collection of listeners who need to be informed each time the stream is bound to a value |
private java.util.Queue |
requests
|
private java.util.Collection |
wheneverBoundListeners
|
Constructor Summary | |
DataflowQueue()
|
Method Summary | |
---|---|
void
|
binaryChoice(DataflowWriteChannel trueBranch, DataflowWriteChannel falseBranch, groovy.lang.Closure code)
|
void
|
binaryChoice(Pool pool, DataflowWriteChannel trueBranch, DataflowWriteChannel falseBranch, groovy.lang.Closure code)
|
void
|
binaryChoice(PGroup group, DataflowWriteChannel trueBranch, DataflowWriteChannel falseBranch, groovy.lang.Closure code)
|
void
|
binaryChoice(java.util.Map params, DataflowWriteChannel trueBranch, DataflowWriteChannel falseBranch, groovy.lang.Closure code)
|
void
|
binaryChoice(Pool pool, java.util.Map params, DataflowWriteChannel trueBranch, DataflowWriteChannel falseBranch, groovy.lang.Closure code)
|
void
|
binaryChoice(PGroup group, java.util.Map params, DataflowWriteChannel trueBranch, DataflowWriteChannel falseBranch, groovy.lang.Closure code)
|
void
|
bind(java.lang.Object value)
Hooks the registered when bound handlers to the supplied dataflow expression |
DataflowReadChannel
|
chainWith(groovy.lang.Closure closure)
|
DataflowReadChannel
|
chainWith(Pool pool, groovy.lang.Closure closure)
|
DataflowReadChannel
|
chainWith(PGroup group, groovy.lang.Closure closure)
|
DataflowReadChannel
|
chainWith(java.util.Map params, groovy.lang.Closure closure)
|
DataflowReadChannel
|
chainWith(Pool pool, java.util.Map params, groovy.lang.Closure closure)
|
DataflowReadChannel
|
chainWith(PGroup group, java.util.Map params, groovy.lang.Closure closure)
|
void
|
choice(java.util.List outputs, groovy.lang.Closure code)
|
void
|
choice(Pool pool, java.util.List outputs, groovy.lang.Closure code)
|
void
|
choice(PGroup group, java.util.List outputs, groovy.lang.Closure code)
|
void
|
choice(java.util.Map params, java.util.List outputs, groovy.lang.Closure code)
|
void
|
choice(Pool pool, java.util.Map params, java.util.List outputs, groovy.lang.Closure code)
|
void
|
choice(PGroup group, java.util.Map params, java.util.List outputs, groovy.lang.Closure code)
|
private DataflowVariable
|
copyDFV(java.util.Queue from, java.util.Queue to)
|
protected DataflowVariable
|
createVariable()
Retrieves the value at the head of the buffer. |
DataflowReadChannel
|
filter(groovy.lang.Closure closure)
|
DataflowReadChannel
|
filter(Pool pool, groovy.lang.Closure closure)
|
DataflowReadChannel
|
filter(PGroup group, groovy.lang.Closure closure)
|
DataflowReadChannel
|
filter(java.util.Map params, groovy.lang.Closure closure)
|
DataflowReadChannel
|
filter(Pool pool, java.util.Map params, groovy.lang.Closure closure)
|
DataflowReadChannel
|
filter(PGroup group, java.util.Map params, groovy.lang.Closure closure)
|
private void
|
fireOnMessage(java.lang.Object value)
|
DataflowChannelEventListenerManager
|
getEventManager()
|
java.util.concurrent.LinkedBlockingQueue
|
getQueue()
|
java.lang.Object
|
getVal()
Retrieves the value at the head of the buffer. |
java.lang.Object
|
getVal(long timeout, java.util.concurrent.TimeUnit units)
|
void
|
getValAsync(MessageStream callback)
Asynchronously retrieves the value at the head of the buffer. |
void
|
getValAsync(java.lang.Object attachment, MessageStream callback)
Schedule closure to be executed by pooled actor after data became available. |
private DataflowExpression
|
hookWheneverBoundListeners(DataflowExpression expr)
Takes the first unsatisfied value request and binds a value on it. |
void
|
into(DataflowWriteChannel target)
|
void
|
into(Pool pool, DataflowWriteChannel target)
|
void
|
into(PGroup group, DataflowWriteChannel target)
|
void
|
into(java.util.Map params, DataflowWriteChannel target)
|
void
|
into(Pool pool, java.util.Map params, DataflowWriteChannel target)
|
void
|
into(PGroup group, java.util.Map params, DataflowWriteChannel target)
|
boolean
|
isBound()
Checks whether there's a DFV waiting in the queue and retrieves it. |
java.util.Iterator
|
iterator()
|
DataflowWriteChannel
|
leftShift(DataflowReadChannel ref)
|
DataflowWriteChannel
|
leftShift(java.lang.Object value)
Adds a DataflowVariable representing the passed in value to the buffer. |
int
|
length()
|
DataflowReadChannel
|
merge(DataflowReadChannel other, groovy.lang.Closure closure)
|
DataflowReadChannel
|
merge(Pool pool, DataflowReadChannel other, groovy.lang.Closure closure)
|
DataflowReadChannel
|
merge(PGroup group, DataflowReadChannel other, groovy.lang.Closure closure)
|
DataflowReadChannel
|
merge(java.util.List others, groovy.lang.Closure closure)
|
DataflowReadChannel
|
merge(Pool pool, java.util.List others, groovy.lang.Closure closure)
|
DataflowReadChannel
|
merge(PGroup group, java.util.List others, groovy.lang.Closure closure)
|
DataflowReadChannel
|
merge(java.util.Map params, DataflowReadChannel other, groovy.lang.Closure closure)
|
DataflowReadChannel
|
merge(Pool pool, java.util.Map params, DataflowReadChannel other, groovy.lang.Closure closure)
|
DataflowReadChannel
|
merge(PGroup group, java.util.Map params, DataflowReadChannel other, groovy.lang.Closure closure)
|
DataflowReadChannel
|
merge(java.util.Map params, java.util.List others, groovy.lang.Closure closure)
|
DataflowReadChannel
|
merge(Pool pool, java.util.Map params, java.util.List others, groovy.lang.Closure closure)
|
DataflowReadChannel
|
merge(PGroup group, java.util.Map params, java.util.List others, groovy.lang.Closure closure)
|
DataflowReadChannel
|
or(groovy.lang.Closure closure)
|
void
|
or(DataflowWriteChannel target)
|
DataflowExpression
|
poll()
|
private DataflowVariable
|
retrieveForBind()
|
private DataflowVariable
|
retrieveOrCreateVariable()
Returns the current size of the buffer |
Promise
|
rightShift(groovy.lang.Closure closure)
Schedule closure to be executed by pooled actor after the next data becomes available. |
void
|
separate(java.util.List outputs, groovy.lang.Closure code)
|
void
|
separate(Pool pool, java.util.List outputs, groovy.lang.Closure code)
|
void
|
separate(PGroup group, java.util.List outputs, groovy.lang.Closure code)
|
void
|
separate(java.util.Map params, java.util.List outputs, groovy.lang.Closure code)
|
void
|
separate(Pool pool, java.util.Map params, java.util.List outputs, groovy.lang.Closure code)
|
void
|
separate(PGroup group, java.util.Map params, java.util.List outputs, groovy.lang.Closure code)
|
void
|
split(DataflowWriteChannel target1, DataflowWriteChannel target2)
|
void
|
split(Pool pool, DataflowWriteChannel target1, DataflowWriteChannel target2)
|
void
|
split(PGroup group, DataflowWriteChannel target1, DataflowWriteChannel target2)
|
void
|
split(java.util.List targets)
|
void
|
split(Pool pool, java.util.List targets)
|
void
|
split(PGroup group, java.util.List targets)
|
void
|
split(java.util.Map params, DataflowWriteChannel target1, DataflowWriteChannel target2)
|
void
|
split(Pool pool, java.util.Map params, DataflowWriteChannel target1, DataflowWriteChannel target2)
|
void
|
split(PGroup group, java.util.Map params, DataflowWriteChannel target1, DataflowWriteChannel target2)
|
void
|
split(java.util.Map params, java.util.List targets)
|
void
|
split(Pool pool, java.util.Map params, java.util.List targets)
|
void
|
split(PGroup group, java.util.Map params, java.util.List targets)
|
DataflowReadChannel
|
tap(DataflowWriteChannel target)
|
DataflowReadChannel
|
tap(Pool pool, DataflowWriteChannel target)
|
DataflowReadChannel
|
tap(PGroup group, DataflowWriteChannel target)
|
DataflowReadChannel
|
tap(java.util.Map params, DataflowWriteChannel target)
|
DataflowReadChannel
|
tap(Pool pool, java.util.Map params, DataflowWriteChannel target)
|
DataflowReadChannel
|
tap(PGroup group, java.util.Map params, DataflowWriteChannel target)
|
Promise
|
then(groovy.lang.Closure closure)
|
Promise
|
then(Pool pool, groovy.lang.Closure closure)
|
Promise
|
then(PGroup group, groovy.lang.Closure closure)
Send all pieces of data bound in the future to the provided stream when it becomes available |
java.lang.String
|
toString()
|
void
|
whenBound(groovy.lang.Closure closure)
Schedule closure to be executed by pooled actor after data becomes available. |
void
|
whenBound(Pool pool, groovy.lang.Closure closure)
Send the next bound piece of data to the provided stream when it becomes available. |
void
|
whenBound(PGroup group, groovy.lang.Closure closure)
|
void
|
whenBound(MessageStream stream)
Schedule closure to be executed after data became available. |
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)
|
Methods inherited from class java.lang.Object | |
---|---|
java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
Field Detail |
---|
private DataflowChannelEventOrchestrator eventManager
private final java.util.concurrent.LinkedBlockingQueue queue
private final java.lang.Object queueLock
private final java.util.Queue requests
private final java.util.Collection wheneverBoundListeners
Constructor Detail |
---|
DataflowQueue()
Method Detail |
---|
@java.lang.Override public void binaryChoice(DataflowWriteChannel trueBranch, DataflowWriteChannel falseBranch, groovy.lang.Closure code)
@java.lang.Override public void binaryChoice(Pool pool, DataflowWriteChannel trueBranch, DataflowWriteChannel falseBranch, groovy.lang.Closure code)
@java.lang.Override public void binaryChoice(PGroup group, DataflowWriteChannel trueBranch, DataflowWriteChannel falseBranch, groovy.lang.Closure code)
@java.lang.Override public void binaryChoice(java.util.Map params, DataflowWriteChannel trueBranch, DataflowWriteChannel falseBranch, groovy.lang.Closure code)
@java.lang.Overridepublic void choice(final List> outputs, final Closure code) { public void binaryChoice(Pool pool, java.util.Map params, DataflowWriteChannel trueBranch, DataflowWriteChannel falseBranch, groovy.lang.Closure code)
@java.lang.Overridepublic void choice(final Pool pool, final List> outputs, final Closure code) { public void binaryChoice(PGroup group, java.util.Map params, DataflowWriteChannel trueBranch, DataflowWriteChannel falseBranch, groovy.lang.Closure code)
@java.lang.Override} public final void bind(java.lang.Object value)
expr
- The expression to hook all the when bound listeners to
@java.lang.Override} public final DataflowReadChannel chainWith(groovy.lang.Closure closure)
@java.lang.Override} public final DataflowReadChannel chainWith(Pool pool, groovy.lang.Closure closure)
@java.lang.Override} public DataflowReadChannel chainWith(PGroup group, groovy.lang.Closure closure)
@java.lang.Overrideparameters.put("outputs", asList(result)); public final DataflowReadChannel chainWith(java.util.Map params, groovy.lang.Closure closure)
@java.lang.Override public final DataflowReadChannel chainWith(Pool pool, java.util.Map params, groovy.lang.Closure closure)
@java.lang.Override public DataflowReadChannel chainWith(PGroup group, java.util.Map params, groovy.lang.Closure closure)
@java.lang.Override public void choice(java.util.List outputs, groovy.lang.Closure code)
@java.lang.Override public void choice(Pool pool, java.util.List outputs, groovy.lang.Closure code)
@java.lang.Override public void choice(PGroup group, java.util.List outputs, groovy.lang.Closure code)
@java.lang.Override public void choice(java.util.Map params, java.util.List outputs, groovy.lang.Closure code)
@java.lang.Overridepublic void separate(final List> outputs, final Closure > code) { public void choice(Pool pool, java.util.Map params, java.util.List outputs, groovy.lang.Closure code)
@java.lang.Overridepublic void separate(final Pool pool, final List> outputs, final Closure > code) { public void choice(PGroup group, java.util.Map params, java.util.List outputs, groovy.lang.Closure code)
private DataflowVariable copyDFV(java.util.Queue from, java.util.Queue to)
protected DataflowVariable createVariable()
@java.lang.Override public DataflowReadChannel filter(groovy.lang.Closure closure)
@java.lang.Override public DataflowReadChannel filter(Pool pool, groovy.lang.Closure closure)
@java.lang.Override public DataflowReadChannel filter(PGroup group, groovy.lang.Closure closure)
@java.lang.Override public DataflowReadChannel filter(java.util.Map params, groovy.lang.Closure closure)
@java.lang.Override public DataflowReadChannel filter(Pool pool, java.util.Map params, groovy.lang.Closure closure)
@java.lang.Override public DataflowReadChannel filter(PGroup group, java.util.Map params, groovy.lang.Closure closure)
private void fireOnMessage(java.lang.Object value)
@java.lang.Override} public DataflowChannelEventListenerManager getEventManager()
final java.util.concurrent.LinkedBlockingQueue getQueue()
@java.lang.Overridefinal DataflowVariablevariable = retrieveOrCreateVariable(); public final java.lang.Object getVal()
timeout
- The timeout valueunits
- Units for the timeout
@java.lang.Override* public final java.lang.Object getVal(long timeout, java.util.concurrent.TimeUnit units)
@java.lang.Override public final void getValAsync(MessageStream callback)
attachment
- An arbitrary value to identify operator channels and so match requests and repliescallback
- The actor / operator to notify when a value is bound
@java.lang.Override} public final void getValAsync(java.lang.Object attachment, MessageStream callback)
closure
- closure to execute when data becomes available. The closure should take at most one argument.
private DataflowExpression hookWheneverBoundListeners(DataflowExpression expr)
@java.lang.Override public void into(DataflowWriteChannel target)
@java.lang.Override public void into(Pool pool, DataflowWriteChannel target)
@java.lang.Override public void into(PGroup group, DataflowWriteChannel target)
@java.lang.Overridegroup.operator(parameters, new ChainWithClosure(new CopyChannelsClosure())); public void into(java.util.Map params, DataflowWriteChannel target)
@java.lang.Overrideinto(target); public void into(Pool pool, java.util.Map params, DataflowWriteChannel target)
@java.lang.Overridesplit(Dataflow.retrieveCurrentDFPGroup(), target1, target2); public void into(PGroup group, java.util.Map params, DataflowWriteChannel target)
@java.lang.Override/** public final boolean isBound()
public final java.util.Iterator iterator()
@java.lang.Override}); @java.lang.SuppressWarningsreturn this; public final DataflowWriteChannel leftShift(DataflowReadChannel ref)
@java.lang.OverridefireOnMessage(value); public final DataflowWriteChannel leftShift(java.lang.Object value)
value
- The value to bind to the head of the stream
@java.lang.Override public final int length()
@java.lang.Override public DataflowReadChannel merge(DataflowReadChannel other, groovy.lang.Closure closure)
@java.lang.Override public DataflowReadChannel merge(Pool pool, DataflowReadChannel other, groovy.lang.Closure closure)
@java.lang.Override public DataflowReadChannel merge(PGroup group, DataflowReadChannel other, groovy.lang.Closure closure)
@java.lang.Overrideinputs.addAll(others); public DataflowReadChannel merge(java.util.List others, groovy.lang.Closure closure)
@java.lang.Override public DataflowReadChannel merge(Pool pool, java.util.List others, groovy.lang.Closure closure)
@java.lang.Override public DataflowReadChannel merge(PGroup group, java.util.List others, groovy.lang.Closure closure)
@java.lang.Override public DataflowReadChannel merge(java.util.Map params, DataflowReadChannel other, groovy.lang.Closure closure)
@java.lang.Override public DataflowReadChannel merge(Pool pool, java.util.Map params, DataflowReadChannel other, groovy.lang.Closure closure)
@java.lang.Override public DataflowReadChannel merge(PGroup group, java.util.Map params, DataflowReadChannel other, groovy.lang.Closure closure)
@java.lang.Overrideinputs.addAll(others); public DataflowReadChannel merge(java.util.Map params, java.util.List others, groovy.lang.Closure closure)
@java.lang.Overridereturn result; public DataflowReadChannel merge(Pool pool, java.util.Map params, java.util.List others, groovy.lang.Closure closure)
@java.lang.OverridebinaryChoice(Dataflow.retrieveCurrentDFPGroup(), trueBranch, falseBranch, code); public DataflowReadChannel merge(PGroup group, java.util.Map params, java.util.List others, groovy.lang.Closure closure)
@java.lang.Override public DataflowReadChannel or(groovy.lang.Closure closure)
@java.lang.Override public void or(DataflowWriteChannel target)
@java.lang.Override* The actor can perform other activities or release a thread back to the pool by calling react() waiting for the message public final DataflowExpression poll()
private DataflowVariable retrieveForBind()
private DataflowVariable retrieveOrCreateVariable()
@java.lang.Override} public final Promise rightShift(groovy.lang.Closure closure)
closure
- closure to execute when data becomes available. The closure should take at most one argument.
@java.lang.Override public void separate(java.util.List outputs, groovy.lang.Closure code)
@java.lang.Override public void separate(Pool pool, java.util.List outputs, groovy.lang.Closure code)
@java.lang.Override public void separate(PGroup group, java.util.List outputs, groovy.lang.Closure code)
@java.lang.Override public void separate(java.util.Map params, java.util.List outputs, groovy.lang.Closure code)
@java.lang.Override* Check if value has been set already for this expression public void separate(Pool pool, java.util.Map params, java.util.List outputs, groovy.lang.Closure code)
@java.lang.Overridepublic final boolean isBound() { public void separate(PGroup group, java.util.Map params, java.util.List outputs, groovy.lang.Closure code)
@java.lang.Override public void split(DataflowWriteChannel target1, DataflowWriteChannel target2)
@java.lang.Override public void split(Pool pool, DataflowWriteChannel target1, DataflowWriteChannel target2)
@java.lang.Override public void split(PGroup group, DataflowWriteChannel target1, DataflowWriteChannel target2)
@java.lang.Override public void split(java.util.List targets)
@java.lang.Override public void split(Pool pool, java.util.List targets)
@java.lang.Override public void split(PGroup group, java.util.List targets)
@java.lang.Override public void split(java.util.Map params, DataflowWriteChannel target1, DataflowWriteChannel target2)
@java.lang.Override public void split(Pool pool, java.util.Map params, DataflowWriteChannel target1, DataflowWriteChannel target2)
@java.lang.Override public void split(PGroup group, java.util.Map params, DataflowWriteChannel target1, DataflowWriteChannel target2)
@java.lang.Override public void split(java.util.Map params, java.util.List targets)
@java.lang.Overridepublic DataflowReadChanneltap(final DataflowWriteChannel target) { public void split(Pool pool, java.util.Map params, java.util.List targets)
@java.lang.Overridepublic DataflowReadChanneltap(final Pool pool, final DataflowWriteChannel target) { public void split(PGroup group, java.util.Map params, java.util.List targets)
@java.lang.Override} public DataflowReadChannel tap(DataflowWriteChannel target)
@java.lang.Override} public DataflowReadChannel tap(Pool pool, DataflowWriteChannel target)
@java.lang.Override} public DataflowReadChannel tap(PGroup group, DataflowWriteChannel target)
@java.lang.Overrideparameters.put("outputs", asList(result, target)); public DataflowReadChannel tap(java.util.Map params, DataflowWriteChannel target)
@java.lang.Override public DataflowReadChannel tap(Pool pool, java.util.Map params, DataflowWriteChannel target)
@java.lang.Override public DataflowReadChannel tap(PGroup group, java.util.Map params, DataflowWriteChannel target)
@java.lang.Override*/ public final Promise then(groovy.lang.Closure closure)
@java.lang.Override*/ public Promise then(Pool pool, groovy.lang.Closure closure)
@java.lang.Override} public Promise then(PGroup group, groovy.lang.Closure closure)
closure
- closure to execute when data becomes available. The closure should take at most one argument.
@java.lang.Override public java.lang.String toString()
@java.lang.OverridegetValAsync(new DataCallbackWithPool(pool, closure)); public final void whenBound(groovy.lang.Closure closure)
pool
- The thread pool to use for task scheduling for asynchronous message deliveryclosure
- closure to execute when data becomes available. The closure should take at most one argument.
@java.lang.Override public final void whenBound(Pool pool, groovy.lang.Closure closure)
stream
- stream where to send result
@java.lang.Override/** public void whenBound(PGroup group, groovy.lang.Closure closure)
@java.lang.Overridefinal DataflowVariableresult = new DataflowVariable (); public final void whenBound(MessageStream stream)
closure
- closure to execute when data becomes available. The closure should take at most one argument.
@java.lang.Override public final void wheneverBound(groovy.lang.Closure closure)
stream
- stream where to send result
@java.lang.Override public final void wheneverBound(MessageStream stream)
Copyright © 2008–2013 Václav Pech. All Rights Reserved.