CSP for Java
(JCSP) 1.0-rc4

jcsp.util
Interface ChannelDataStore

All Superinterfaces:
Cloneable
All Known Implementing Classes:
Buffer, InfiniteBuffer, OverFlowingBuffer, OverWriteOldestBuffer, ZeroBuffer, OverWritingBuffer

public interface ChannelDataStore
extends Cloneable

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

Description

ChannelDataStore defines the interface to the logic used by channels defined in the 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 create methods of One2OneChannel etc.

Note: instances of ChannelDataStore implementations are used by the various channel classes within jcsp.lang in a thread-safe way. They are not intended for any other purpose. Developers of new ChannelDataStore 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:
ZeroBuffer, Buffer, OverWriteOldestBuffer, OverWritingBuffer, OverFlowingBuffer, InfiniteBuffer, One2OneChannel, Any2OneChannel, One2AnyChannel, Any2AnyChannel

Field Summary
static int EMPTY
          Indicates that the ChannelDataStore is empty -- it can accept only a put.
static int FULL
          Indicates that the ChannelDataStore is full -- it can accept only a get.
static int NONEMPTYFULL
          Indicates that the ChannelDataStore is neither empty nor full -- it can accept either a put or a get call.
 
Method Summary
 Object clone()
          Returns a new (and EMPTY) ChannelDataStore with the same creation parameters as this one.
 Object get()
          Returns an Object from the ChannelDataStore.
 int getState()
          Returns the current state of the ChannelDataStore.
 void put(Object value)
          Puts a new Object into the ChannelDataStore.
 

Field Detail

EMPTY

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

NONEMPTYFULL

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

FULL

public static final int FULL
Indicates that the ChannelDataStore is full -- it can accept only a get.
Method Detail

getState

public int getState()
Returns the current state of the ChannelDataStore.
Returns:
the current state of the ChannelDataStore (EMPTY, NONEMPTYFULL or FULL)

put

public void put(Object value)
Puts a new Object into the ChannelDataStore.

Pre-condition: getState must not currently return FULL.

Parameters:
value - the Object to put into the ChannelDataStore

get

public Object get()
Returns an Object from the ChannelDataStore.

Pre-condition: getState must not currently return EMPTY.

Returns:
an Object from the ChannelDataStore

clone

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

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

Overrides:
clone in class Object
Returns:
the cloned instance of this ChannelDataStore.

CSP for Java
(JCSP) 1.0-rc4

Submit a bug or feature to jcsp-team@ukc.ac.uk
Version 1.0-rc4 of the JCSP API Specification (Copyright 1997-2000 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.