|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object groovyx.gpars.dataflow.stream.DataflowStreamReadAdapter<T>
T
- The type of messages to pass through the streampublic final class DataflowStreamReadAdapter<T>
Adapts a DataflowStream to accommodate for the DataflowReadChannel interface. To minimize the overhead and stay in-line with the DataflowStream semantics, the DataflowStreamReadAdapter class is not thread-safe and should only be used from within a single thread. If multiple threads need to read from a DataflowStream, they should each create their own wrapping DataflowStreamReadAdapter.
Field Summary | |
---|---|
private DataflowStream<T> |
asyncHead
|
private DataflowStream<T> |
head
|
Constructor Summary | |
---|---|
DataflowStreamReadAdapter(DataflowStream<T> stream)
Creates a new adapter |
Method Summary | |
---|---|
T |
getVal()
Reads the current value of the channel. |
T |
getVal(long timeout,
java.util.concurrent.TimeUnit units)
Reads the current value of the channel. |
void |
getValAsync(MessageStream callback)
Asynchronously retrieves the value from the channel. |
void |
getValAsync(java.lang.Object attachment,
MessageStream callback)
Asynchronously retrieves the value from the channel. |
boolean |
isBound()
Check if value has been set already for this expression |
java.util.Iterator<T> |
iterator()
|
private void |
moveAsyncHead()
|
private void |
moveHead()
|
DataflowExpression<T> |
poll()
Retrieves the value at the head 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 |
java.lang.String |
toString()
|
void |
whenBound(groovy.lang.Closure closure)
Schedule closure to be executed by pooled actor 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 the bound data to provided stream when it becomes available |
void |
whenBound(groovyx.gpars.group.PGroup group,
groovy.lang.Closure closure)
Schedule closure to be executed by pooled actor 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(Pool pool,
groovy.lang.Closure closure)
Schedule closure to be executed by pooled actor 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 |
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)
Send all pieces of data bound in the future to the provided stream when it becomes available |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private DataflowStream<T> head
private DataflowStream<T> asyncHead
Constructor Detail |
---|
public DataflowStreamReadAdapter(DataflowStream<T> stream)
stream
- The stream to wrapMethod Detail |
---|
public java.util.Iterator<T> iterator()
public java.lang.String toString()
toString
in class java.lang.Object
public T getVal() throws java.lang.InterruptedException
DataflowReadChannel
getVal
in interface DataflowReadChannel<T>
java.lang.InterruptedException
- If the current thread gets interrupted while waiting for the channel to be boundpublic T getVal(long timeout, java.util.concurrent.TimeUnit units) throws java.lang.InterruptedException
DataflowReadChannel
getVal
in interface DataflowReadChannel<T>
timeout
- The timeout valueunits
- Units for the timeout
java.lang.InterruptedException
- If the current thread gets interrupted while waiting for the channel to be boundpublic void getValAsync(MessageStream callback)
DataflowReadChannel
getValAsync
in interface DataflowReadChannel<T>
callback
- An actor to send the bound value to.public void getValAsync(java.lang.Object attachment, MessageStream callback)
DataflowReadChannel
getValAsync
in interface DataflowReadChannel<T>
attachment
- arbitrary non-null attachment if reader needs better identification of resultcallback
- An actor to send the bound value plus the supplied index to.public void rightShift(groovy.lang.Closure closure)
DataflowReadChannel
rightShift
in interface DataflowReadChannel<T>
closure
- closure to execute when data availablepublic void whenBound(groovy.lang.Closure closure)
DataflowReadChannel
whenBound
in interface DataflowReadChannel<T>
closure
- closure to execute when data availablepublic void whenBound(Pool pool, groovy.lang.Closure closure)
whenBound
in interface DataflowReadChannel<T>
pool
- The thread pool to use for task scheduling for asynchronous message deliveryclosure
- closure to execute when data availablepublic void whenBound(groovyx.gpars.group.PGroup group, groovy.lang.Closure closure)
DataflowReadChannel
whenBound
in interface DataflowReadChannel<T>
group
- The PGroup to use for task scheduling for asynchronous message deliveryclosure
- closure to execute when data availablepublic void whenBound(MessageStream stream)
DataflowReadChannel
whenBound
in interface DataflowReadChannel<T>
stream
- stream where to send resultpublic void wheneverBound(groovy.lang.Closure closure)
DataflowReadChannel
wheneverBound
in interface DataflowReadChannel<T>
closure
- closure to execute when data availablepublic void wheneverBound(MessageStream stream)
DataflowReadChannel
wheneverBound
in interface DataflowReadChannel<T>
stream
- stream where to send resultpublic boolean isBound()
DataflowReadChannel
isBound
in interface DataflowReadChannel<T>
public DataflowExpression<T> poll() throws java.lang.InterruptedException
DataflowReadChannel
poll
in interface DataflowReadChannel<T>
java.lang.InterruptedException
- If the current thread is interruptedprivate void moveHead()
private void moveAsyncHead()
|
Copyright © 2008–2010 Václav Pech. All Rights Reserved. | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |