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 streamFields inherited from class | Fields |
---|---|
class DataflowStreamWriteAdapter |
head |
class WithSerialId |
serialHandle, serialVersionUID |
Constructor and description |
---|
SyncDataflowBroadcast
() Creates a new instance |
Type | Name and description |
---|---|
DataflowReadChannel<T> |
createReadChannel() Retrieves an implementation of DataflowReadChannel to read all messages submitted to the broadcast chanel. |
java.lang.String |
toString() |
void |
unsubscribeReadChannel(DataflowReadChannel<T> channel) Un-registers the supplied read channel from the broadcast. |
Methods inherited from class | Name |
---|---|
class DataflowStreamWriteAdapter |
bind, getHead, leftShift, leftShift, notifyRemote, toString, updateHead |
class WithSerialId |
createRemoteHandle, getOrCreateSerialHandle, getRemoteClass, writeReplace |
class java.lang.Object |
java.lang.Object#wait(), java.lang.Object#wait(long, int), java.lang.Object#wait(long), 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() |
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.
Un-registers the supplied read channel from the broadcast. The number of parties that have to meet at data exchange is reduced by one.
channel
- The channel to unsubscribe. The channel won't be able to read further messages.Copyright © 2008–2014 Václav Pech. All Rights Reserved.