groovyx.gpars.dataflow
[Java] Class DataflowBroadcast
java.lang.Object
groovyx.gpars.dataflow.stream.DataflowStreamWriteAdapter
groovyx.gpars.dataflow.DataflowBroadcast
public final class DataflowBroadcast
extends DataflowStreamWriteAdapter
Offers a deterministic one-to-many and many-to-many messaging alternative to DataflowQueue.
Internally it wraps a DataflowStream class with a DataflowStreamWriteAdapter and so
synchronizes all writes to the underlying stream allowing multiple threads accessing the stream concurrently.
On demand through the createReadChannel() method it will return an DataflowReadChannel through which the reader will receive
all messages written to the channel since then.
Typical use:
DataflowWriteChannel broadcastStream = new DataflowBroadcast()
DataflowReadChannel stream1 = broadcastStream.createReadChannel()
DataflowReadChannel stream2 = broadcastStream.createReadChannel()
broadcastStream << 'Message'
assert stream1.val == stream2.val
- Parameters:
- The type of messages to pass through the stream
- Authors:
- Vaclav Pech
Methods inherited from class java.lang.Object
|
java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#wait(long, int), 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() |
DataflowBroadcast
public DataflowBroadcast()
- Creates a new adapter
createReadChannel
public DataflowReadChannel createReadChannel()
- Retrieves an implementation of DataflowReadChannel to read all messages submitted to the broadcast chanel.
Since multiple parties (threads/tasks/actors/...) may ask for read channels independently, the submitted messages are effectively
broadcast to all the subscribers.
- Returns:
- A read channel to receive messages submitted to the broadcast channel from now on.
toString
@SuppressWarnings({"SynchronizedMethod"})
@Override
public java.lang.String toString()
-
Copyright © 2008–2010 Václav Pech. All Rights Reserved.