groovyx.gpars.dataflow.stream
Class DataflowStreamWriteAdapter<T>

java.lang.Object
  extended by groovyx.gpars.dataflow.stream.DataflowStreamWriteAdapter<T>
Type Parameters:
T - The type of messages to pass through the stream
All Implemented Interfaces:
DataflowWriteChannel<T>
Direct Known Subclasses:
DataflowBroadcast, SyncDataflowBroadcast

public class DataflowStreamWriteAdapter<T>
extends java.lang.Object
implements DataflowWriteChannel<T>

Adapts a DataflowStream to accommodate for the DataflowWriteChannel interface. It also synchronizes all changes to the underlying stream allowing multiple threads accessing the stream concurrently.

Author:
Vaclav Pech

Field Summary
private  StreamCore<T> head
           
 
Constructor Summary
DataflowStreamWriteAdapter(StreamCore<T> stream)
          Creates a new adapter
 
Method Summary
 void bind(T value)
          Assigns a value to the variable.
protected  StreamCore<T> getHead()
           
 DataflowWriteChannel<T> leftShift(DataflowReadChannel<T> ref)
          Assigns a value from one DataflowVariable instance to this variable.
 DataflowWriteChannel<T> leftShift(T value)
          Assigns a value to the variable.
 java.lang.String toString()
           
private  StreamCore<T> updateHead()
          Moves head
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

head

private StreamCore<T> head
Constructor Detail

DataflowStreamWriteAdapter

public DataflowStreamWriteAdapter(StreamCore<T> stream)
Creates a new adapter

Parameters:
stream - The stream to wrap
Method Detail

leftShift

public final DataflowWriteChannel<T> leftShift(T value)
Description copied from interface: DataflowWriteChannel
Assigns a value to the variable. Can only be invoked once on each instance of DataflowVariable

Specified by:
leftShift in interface DataflowWriteChannel<T>
Parameters:
value - The value to assign
Returns:
The current channel instance

leftShift

public final DataflowWriteChannel<T> leftShift(DataflowReadChannel<T> ref)
Description copied from interface: DataflowWriteChannel
Assigns a value from one DataflowVariable instance to this variable. Can only be invoked once on each instance of DataflowVariable

Specified by:
leftShift in interface DataflowWriteChannel<T>
Parameters:
ref - The DataflowVariable instance the value of which to bind
Returns:
The current channel instance

bind

public final void bind(T value)
Description copied from interface: DataflowWriteChannel
Assigns a value to the variable. Can only be invoked once on each instance of DataflowVariable

Specified by:
bind in interface DataflowWriteChannel<T>
Parameters:
value - The value to assign

updateHead

private StreamCore<T> updateHead()
Moves head

Returns:
The old head

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getHead

protected final StreamCore<T> getHead()

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