CSP for Java
(JCSP) 1.1-rc4

org.jcsp.util.ints
Interface ChannelDataStoreInt

All Superinterfaces:
Cloneable
All Known Implementing Classes:
BufferInt, InfiniteBufferInt, OverFlowingBufferInt, OverWriteOldestBufferInt, OverWritingBufferInt, ZeroBufferInt

public interface ChannelDataStoreInt
extends Cloneable

This is the interface for integer channel plug-ins that define their buffering characteristics.

Description

ChannelDataStoreInt defines the interface to the logic used by the integer channels defined in the org.jcsp.lang package to manage the data being communicated.

This enables that logic to be varied by creating channels specifying a particular implementation of this interface. This reduces the number of classes that would otherwise need to be defined. The default channel constructor (with no parameters) uses the ZeroBuffer implementation, which gives the standard CSP semantics -- no buffering and full synchronisation between reading and writing processes. See the static construction methods of Channel (Channel.one2oneInt(org.jcsp.util.ints.ChannelDataStoreInt) etc.).

Note: instances of ChannelDataStoreInt implementations are used by the various channel classes within org.jcsp.lang in a thread-safe way. They are not intended for any other purpose. Developers of new ChannelDataStoreInt implementations, therefore, do not need to worry about thread safety (e.g. by making its methods synchronized). Also, developers can assume that the documented pre-conditions for invoking the get and put methods will be met.

Author:
P.D. Austin
See Also:
ZeroBufferInt, BufferInt, OverWriteOldestBufferInt, OverWritingBufferInt, OverFlowingBufferInt, InfiniteBufferInt, ChannelInt

Field Summary
static int EMPTY
          Indicates that the ChannelDataStoreInt is empty -- it can accept only a put.
static int FULL
          Indicates that the ChannelDataStoreInt is full -- it can accept only a get.
static int NONEMPTYFULL
          Indicates that the ChannelDataStoreInt is neither empty nor full -- it can accept either a put or a get call.
 
Method Summary
 Object clone()
          Returns a new (and EMPTY) ChannelDataStoreInt with the same creation parameters as this one.
 void endGet()
          Ends an extended read on the buffer.
 int get()
          Returns an int from the ChannelDataStoreInt.
 int getState()
          Returns the current state of the ChannelDataStoreInt.
 void put(int value)
          Puts a new int into the ChannelDataStoreInt.
 void removeAll()
           
 int startGet()
          Begins an extended read on the buffer, returning the data for the extended read Pre-condition: getState must not currently return EMPTY.
 

Field Detail

EMPTY

static final int EMPTY
Indicates that the ChannelDataStoreInt is empty -- it can accept only a put.

See Also:
Constant Field Values

NONEMPTYFULL

static final int NONEMPTYFULL
Indicates that the ChannelDataStoreInt is neither empty nor full -- it can accept either a put or a get call.

See Also:
Constant Field Values

FULL

static final int FULL
Indicates that the ChannelDataStoreInt is full -- it can accept only a get.

See Also:
Constant Field Values
Method Detail

getState

int getState()
Returns the current state of the ChannelDataStoreInt.

Returns:
the current state of the ChannelDataStoreInt (EMPTY, NONEMPTYFULL or FULL)

put

void put(int value)
Puts a new int into the ChannelDataStoreInt.

Pre-condition: getState must not currently return FULL.

Parameters:
value - the int to put into the ChannelDataStoreInt

get

int get()
Returns an int from the ChannelDataStoreInt.

Pre-condition: getState must not currently return EMPTY.

Returns:
an int from the ChannelDataStoreInt

startGet

int startGet()
Begins an extended read on the buffer, returning the data for the extended read Pre-condition: getState must not currently return EMPTY. The exact behaviour of this method depends on your buffer. When a process performs an extended rendezvous on a buffered channel, it will first call this method, then the endGet() method. A FIFO buffer would implement this method as returning the value from the front of the buffer and the next call would remove the value. An overflowing buffer would do the same. However, for an overwriting buffer it is more complex. Refer to the documentation for OverWritingBuffer.startGet() and OverWriteOldestBuffer.startGet() for details

Returns:
The int to be read from the channel at the beginning of the extended rendezvous
See Also:
endGet()

endGet

void endGet()
Ends an extended read on the buffer. The channels guarantee that this method will be called exactly once after each beginExtRead call. During the period between startGet and endGet, it is possible that put(int) will be called, but not get().

See Also:
startGet()

clone

Object clone()
Returns a new (and EMPTY) ChannelDataStoreInt with the same creation parameters as this one.

Note: Only the size and structure of the ChannelDataStoreInt should be cloned, not any stored data.

Returns:
the cloned instance of this ChannelDataStoreInt.

removeAll

void removeAll()

CSP for Java
(JCSP) 1.1-rc4

Submit a bug or feature to jcsp-team@kent.ac.uk
Version 1.1-rc4 of the JCSP API Specification (Copyright 1997-2008 P.D.Austin and P.H.Welch - All Rights Reserved)
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.