|
org.codehaus.gpars | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object groovyx.gpars.dataflow.stream.DataflowStreamWriteAdapter groovyx.gpars.dataflow.SyncDataflowBroadcast
public final class SyncDataflowBroadcast extends DataflowStreamWriteAdapter
Offers a synchronous deterministic one-to-many and many-to-many messaging alternative to SyncDataflowQueue. Internally it wraps a SyncDataflowStream 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
- The type of messages to pass through the streamField Summary |
---|
Fields inherited from class DataflowStreamWriteAdapter | |
---|---|
head |
Constructor Summary | |
SyncDataflowBroadcast()
Creates a new instance |
Method Summary | |
---|---|
DataflowReadChannel
|
createReadChannel()
Retrieves an implementation of DataflowReadChannel to read all messages submitted to the broadcast chanel. |
java.lang.String
|
toString()
|
void
|
unsubscribeReadChannel(DataflowReadChannel channel)
Un-registers the supplied read channel from the broadcast. |
Methods inherited from class DataflowStreamWriteAdapter | |
---|---|
bind, getHead, leftShift, leftShift, toString, updateHead |
Constructor Detail |
---|
public SyncDataflowBroadcast()
Method Detail |
---|
public DataflowReadChannel createReadChannel()
@SuppressWarnings({"SynchronizedMethod"}) @Override public java.lang.String toString()
public void unsubscribeReadChannel(DataflowReadChannel channel)
channel
- The channel to unsubscribe. The channel won't be able to read further messages.
Copyright © 2008–2012 Václav Pech. All Rights Reserved.