All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class jcsp.lang.ints.Many2OneChannelInt

java.lang.Object
   |
   +----jcsp.lang.ints.AltingChannelInputInt
           |
           +----jcsp.lang.ints.AltingChannelInt
                   |
                   +----jcsp.lang.ints.Many2OneChannelInt

public class Many2OneChannelInt
extends AltingChannelInt

Description

The Many2OneChannelInt is an implementation of an AltingChannelInt which is safe to use with only one Reading Process and Many Writing Process. If more than one reader is using the ChannelInt data may read from the ChannelInt more than once. In some cases it may cause the ChannelInt to be left in an unstable state.

This implementation of the ChannelInt uses Objects which conform to the ChannelDataStoreInt interface to store the data sent across the ChannelInt. 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 Many2OneChannelInt. The first of the two can be used to create an array with the default ChannelDataStoreInt and the second allows the type of the ChannelDataStoreInt to be specified.

Author:
P.D.Austin
See Also:
AlternativeInt

Variable Index

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

Constructor Index

 o Many2OneChannelInt()
Constructs a new Many2OneChannelInt with a ZeroBufferInt ChannelDataStoreInt.
 o Many2OneChannelInt(ChannelDataStoreInt)
Constructs a new Many2OneChannelInt with the specified ChannelDataStoreInt.

Method Index

 o create(int)
Creates an array of Many2OneChannelInts.
 o create(int, ChannelDataStoreInt)
Creates an array of Many2OneChannelInt using the specified ChannelDataStoreInt.
 o read()
Reads an int from the ChannelInt.
 o write(int)
Writes an int to the ChannelInt.

Variables

 o data
 protected ChannelDataStoreInt data
The ChannelDataStoreInt used to store the data for the ChannelInt

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

 o writeMonitor
 protected Object writeMonitor
The monitor writes must synchronize on

Constructors

 o Many2OneChannelInt
 public Many2OneChannelInt()
Constructs a new Many2OneChannelInt with a ZeroBufferInt ChannelDataStoreInt.

 o Many2OneChannelInt
 public Many2OneChannelInt(ChannelDataStoreInt o)
Constructs a new Many2OneChannelInt with the specified ChannelDataStoreInt.

Parameters:
data - The ChannelDataStoreInt used to store the data for the ChannelInt

Methods

 o read
 public synchronized int read()
Reads an int from the ChannelInt.

Returns:
The int returned from the ChannelInt.
Overrides:
read in class AltingChannelInputInt
 o write
 public void write(int value)
Writes an int to the ChannelInt. 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 int to write to the ChannelInt.
Overrides:
write in class AltingChannelInt
 o create
 public static Many2OneChannelInt[] create(int n)
Creates an array of Many2OneChannelInts.

Parameters:
n - The number of channels to create in the array
Returns:
The array of Many2OneChannelInt
 o create
 public static Many2OneChannelInt[] create(int n,
                                           ChannelDataStoreInt store)
Creates an array of Many2OneChannelInt using the specified ChannelDataStoreInt.

Parameters:
n - The number of channels to create in the array
Returns:
The array of Many2OneChannelInt

All Packages  Class Hierarchy  This Package  Previous  Next  Index