All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class jcsp.lang.One2ManyChannel

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

public class One2ManyChannel
extends Object
implements Channel

Description

The One2ManyChannel is an implementation of an Channel which is safe to use with many Reading Process and only one Writing Process. If more than one writer is using the Channel data may be lost. 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 One2ManyChannel. 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

Constructor Index

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

Method Index

 o create(int)
Creates an array of One2ManyChannels.
 o create(int, ChannelDataStore)
Creates an array of One2ManyChannel 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

Constructors

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

 o One2ManyChannel
 public One2ManyChannel(ChannelDataStore data)
Constructs a new One2ManyChannel 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 synchronized void write(Object value)
Writes an Object to the Channel.

Parameters:
value - The object to write to the Channel.
 o create
 public static One2ManyChannel[] create(int n)
Creates an array of One2ManyChannels.

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

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

All Packages  Class Hierarchy  This Package  Previous  Next  Index