org.codehaus.gpars

groovyx.gpars.dataflow
[Java] Interface DataflowReadChannel


public interface DataflowReadChannel

A common interface for all dataflow variables, streams or queues

Authors:
Vaclav Pech Date: 21st Sep 2010


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

DataflowExpression 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

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(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 whenBound(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(MessageStream stream)

Send the bound data to provided stream when it becomes 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)

Send all pieces of data bound in the future to the provided stream when it becomes available

 

Method Detail

getVal

public T getVal()
Reads the current value of the channel. Blocks, if the value has not been assigned yet.
throws:
InterruptedException If the current thread gets interrupted while waiting for the channel to be bound
Returns:
The actual value


getVal

public T getVal(long timeout, java.util.concurrent.TimeUnit units)
Reads the current value of the channel. 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 channel to be bound
Parameters:
timeout - The timeout value
units - Units for the timeout
Returns:
The actual value


getValAsync

public void getValAsync(MessageStream callback)
Asynchronously retrieves the value from the channel. Sends the actual value of the channel as a message back the the supplied actor once the value has been bound. The actor can perform other activities or release a thread back to the pool by calling react() waiting for the message with the value of the Dataflow channel.
Parameters:
callback - An actor to send the bound value to.


getValAsync

public void getValAsync(java.lang.Object attachment, MessageStream callback)
Asynchronously retrieves the value from the channel. Sends a message back the the supplied MessageStream with a map holding the supplied attachment under the 'attachment' key and the actual value of the channel under the 'result' key once the value has been bound. Attachment is an arbitrary value helping the actor.operator match its request with the reply. The actor/operator can perform other activities or release a thread back to the pool by calling react() waiting for the message with the value of the Dataflow channel.
Parameters:
attachment - arbitrary non-null attachment if reader needs better identification of result
callback - An actor to send the bound value plus the supplied index to.


isBound

public boolean isBound()
Check if value has been set already for this expression
Returns:
true if bound already


poll

@SuppressWarnings({"ClassReferencesSubclass"})
public DataflowExpression poll()
Retrieves the value at the head of the buffer. Returns null, if no value is available.
throws:
InterruptedException If the current thread is interrupted
Returns:
The value bound to the DFV at the head of the stream or null


rightShift

public 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
Parameters:
closure - closure to execute when data available


whenBound

public 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.
Parameters:
closure - closure to execute when data available


whenBound

public 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.
Parameters:
pool - The thread pool to use for task scheduling for asynchronous message delivery
closure - closure to execute when data available


whenBound

public void whenBound(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.
Parameters:
group - The PGroup to use for task scheduling for asynchronous message delivery
closure - closure to execute when data available


whenBound

public void whenBound(MessageStream stream)
Send the bound data to provided stream when it becomes available
Parameters:
stream - stream where to send result


wheneverBound

public void wheneverBound(groovy.lang.Closure closure)
Send all pieces of data bound in the future to the provided stream when it becomes available *
Parameters:
closure - closure to execute when data available


wheneverBound

public void wheneverBound(MessageStream stream)
Send all pieces of data bound in the future to the provided stream when it becomes available
Parameters:
stream - stream where to send result


 

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