All Packages Class Hierarchy This Package Previous Next Index
Class jcsp.lang.Many2OneChannel
java.lang.Object
|
+----jcsp.lang.AltingChannelInput
|
+----jcsp.lang.AltingChannel
|
+----jcsp.lang.Many2OneChannel
- public class Many2OneChannel
- extends AltingChannel
Description
The Many2OneChannel is an implementation of an AltingChannel which
is safe to use with only one Reading Process and Many Writing Process.
If more than one reader is using the Channel data may read from the
Channel more than once. In some cases it may cause the Channel to be
left in an unstable state.
This implementation of the Channel uses Objects which conform to the
ChannelDataStore interface to store the data sent across the Channel. This
enables the storage policy to be defined when the channel is constructed.
Also system constructors can define their own storage types.
This class also defines two static methods that can be used to create
an array of Many2OneChannel. The first of the two can be used to create
an array with the default ChannelDataStore and the second allows the
type of the ChannelDataStore to be specified.
- Author:
- P.D.Austin
- See Also:
- Alternative
-
alt
- The Alternative class which will control the selection
-
data
- The ChannelDataStore used to store the data for the Channel
-
writeMonitor
- The monitor writes must synchronize on
-
Many2OneChannel()
- Constructs a new Many2OneChannel with a ZeroBuffer ChannelDataStore.
-
Many2OneChannel(ChannelDataStore)
- Constructs a new Many2OneChannel with the specified ChannelDataStore.
-
create(int)
- Creates an array of Many2OneChannels.
-
create(int, ChannelDataStore)
- Creates an array of Many2OneChannel using the specified ChannelDataStore.
-
read()
- Reads an Object from the Channel.
-
write(Object)
- Writes an Object to the Channel.
data
protected ChannelDataStore data
- The ChannelDataStore used to store the data for the Channel
alt
protected Alternative alt
- The Alternative class which will control the selection
writeMonitor
protected Object writeMonitor
- The monitor writes must synchronize on
Many2OneChannel
public Many2OneChannel()
- Constructs a new Many2OneChannel with a ZeroBuffer ChannelDataStore.
Many2OneChannel
public Many2OneChannel(ChannelDataStore o)
- Constructs a new Many2OneChannel with the specified ChannelDataStore.
- Parameters:
- data - The ChannelDataStore used to store the data for the Channel
read
public synchronized Object read()
- Reads an Object from the Channel.
- Returns:
- The object returned from the Channel.
- Overrides:
- read in class AltingChannelInput
write
public void write(Object value)
- Writes an Object to the Channel. This method also ensures only one
of the writers can actually be writing at any time. All other writers
are blocked until it completes the write.
- Parameters:
- value - The object to write to the Channel.
- Overrides:
- write in class AltingChannel
create
public static Many2OneChannel[] create(int n)
- Creates an array of Many2OneChannels.
- Parameters:
- n - The number of channels to create in the array
- Returns:
- The array of Many2OneChannel
create
public static Many2OneChannel[] create(int n,
ChannelDataStore store)
- Creates an array of Many2OneChannel using the specified ChannelDataStore.
- Parameters:
- n - The number of channels to create in the array
- Returns:
- The array of Many2OneChannel
All Packages Class Hierarchy This Package Previous Next Index