All Packages Class Hierarchy This Package Previous Next Index
Class jcsp.lang.One2OneChannel
java.lang.Object
|
+----jcsp.lang.AltingChannelInput
|
+----jcsp.lang.AltingChannel
|
+----jcsp.lang.One2OneChannel
- public class One2OneChannel
- extends AltingChannel
Description
The One2OneChannel is an implementation of an AltingChannel which
is safe to use with only one Reading Process and one Writing Process.
If either more than one reader or writer is using the Channel data may
either be lost or 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 One2OneChannel. 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
-
One2OneChannel()
- Constructs a new One2OneChannel with a ZeroBuffer ChannelDataStore.
-
One2OneChannel(ChannelDataStore)
- Constructs a new One2OneChannel with the specified ChannelDataStore.
-
create(int)
- Creates an array of One2OneChannels.
-
create(int, ChannelDataStore)
- Creates an array of One2OneChannels 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
One2OneChannel
public One2OneChannel()
- Constructs a new One2OneChannel with a ZeroBuffer ChannelDataStore.
One2OneChannel
public One2OneChannel(ChannelDataStore data)
- Constructs a new One2OneChannel 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 synchronized void write(Object value)
- Writes an Object to the Channel.
- Parameters:
- value - The object to write to the Channel.
- Overrides:
- write in class AltingChannel
create
public static One2OneChannel[] create(int n)
- Creates an array of One2OneChannels.
- Parameters:
- n - The number of channels to create in the array
- Returns:
- The array of One2OneChannel
create
public static One2OneChannel[] create(int n,
ChannelDataStore store)
- Creates an array of One2OneChannels using the specified ChannelDataStore.
- Parameters:
- n - The number of channels to create in the array
- Returns:
- The array of One2OneChannel
All Packages Class Hierarchy This Package Previous Next Index