All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class jcsp.lang.Many2ManyChannel

java.lang.Object
   |
   +----jcsp.lang.Many2ManyChannel

public class Many2ManyChannel
extends Object
implements Channel

Description

The Many2ManyChannel is an implementation of an Channel which is safe to use with many Reading Process and many Writing Process.

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 Many2ManyChannel. 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

Variable Index

 o data
The ChannelDataStore used to store the data for the Channel
 o readMonitor
The monitor reads must synchronize on
 o writeMonitor
The monitor writes must synchronize on

Constructor Index

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

Method Index

 o create(int)
Creates an array of Many2ManyChannels.
 o create(int, ChannelDataStore)
Creates an array of Many2ManyChannels 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 readMonitor
 protected Object readMonitor
The monitor reads must synchronize on

 o writeMonitor
 protected Object writeMonitor
The monitor writes must synchronize on

Constructors

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

 o Many2ManyChannel
 public Many2ManyChannel(ChannelDataStore o)
Constructs a new Many2ManyChannel with the specified ChannelDataStore.

Parameters:
data - The ChannelDataStore used to store the data for the Channel

Methods

 o read
 public Object read()
Reads an Object from the Channel. This method also ensures only one of the readers can actually be reading at any time. All other readers are blocked until it completes the read.

Returns:
The object returned from the Channel.
 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.
 o create
 public static Many2ManyChannel[] create(int n)
Creates an array of Many2ManyChannels.

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

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

All Packages  Class Hierarchy  This Package  Previous  Next  Index