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

Variable Index

 o alt
The Alternative class which will control the selection
 o data
The ChannelDataStore used to store the data for the Channel
 o writeMonitor
The monitor writes must synchronize on

Constructor Index

 o Many2OneChannel()
Constructs a new Many2OneChannel with a ZeroBuffer ChannelDataStore.
 o Many2OneChannel(ChannelDataStore)
Constructs a new Many2OneChannel with the specified ChannelDataStore.

Method Index

 o create(int)
Creates an array of Many2OneChannels.
 o create(int, ChannelDataStore)
Creates an array of Many2OneChannel using the specified ChannelDataStore.
 o read()
Reads an Object from the Channel.
 o write(Object)
Writes an Object to the Channel.

Variables

 o data
 protected ChannelDataStore data
The ChannelDataStore used to store the data for the Channel

 o alt
 protected Alternative alt
The Alternative class which will control the selection

 o writeMonitor
 protected Object writeMonitor
The monitor writes must synchronize on

Constructors

 o Many2OneChannel
 public Many2OneChannel()
Constructs a new Many2OneChannel with a ZeroBuffer ChannelDataStore.

 o 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

Methods

 o read
 public synchronized Object read()
Reads an Object from the Channel.

Returns:
The object returned from the Channel.
Overrides:
read in class AltingChannelInput
 o 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
 o 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
 o 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