Package org.jcsp.lang

Class BufferedOne2AnyChannel<T>

java.lang.Object
org.jcsp.lang.One2AnyImpl<T>
org.jcsp.lang.BufferedOne2AnyChannel<T>
All Implemented Interfaces:
ChannelInternals<T>, One2AnyChannel<T>

class BufferedOne2AnyChannel<T> extends One2AnyImpl<T>
This implements an any-to-any object channel with user-definable buffering, safe for use by many writers and many readers.

Description

BufferedOne2AnyChannel implements a one-to-any object channel with user-definable buffering. It is safe for use by any number of reading processes but ony one writer. Reading processes compete with each other to use the channel. Only one reader and the writer will actually be using the channel at any one time. This is taken care of by BufferedOne2AnyChannel -- user processes just read from or write to it.

Please note that this is a safely shared channel and not a multicaster. Currently, multicasting has to be managed by writing active processes (see DynamicDelta for an example of broadcasting).

All reading processes and writing processes commit to the channel (i.e. may not back off). This means that the reading processes may not ALT on this channel.

The constructor requires the user to provide the channel with a plug-in driver conforming to the ChannelDataStore interface. This allows a variety of different channel semantics to be introduced -- including buffered channels of user-defined capacity (including infinite), overwriting channels (with various overwriting policies) etc.. Standard examples are given in the org.jcsp.util package, but careful users may write their own.

Implementation Note and Caution

Fair servicing of readers to this channel depends on the fair servicing of requests to enter a synchronized block (or method) by the underlying Java Virtual Machine (JVM). Java does not specify how threads waiting to synchronize should be handled. Currently, Sun's standard JDKs queue these requests - which is fair. However, there is at least one JVM that puts such competing requests on a stack - which is legal but unfair and can lead to infinite starvation. This is a problem for any Java system relying on good behaviour from synchronized, not just for these 1-any channels.
See Also:
  • Constructor Details

    • BufferedOne2AnyChannel

      public BufferedOne2AnyChannel(ChannelDataStore<T> data)
      Constructs a new BufferedOne2AnyChannel with the specified ChannelDataStore.
      Parameters:
      data - The ChannelDataStore used to store the data for the channel