CSP for Java
(JCSP) 1.0-rc4

jcsp.util
Class ZeroBuffer

java.lang.Object
  |
  +--jcsp.util.ZeroBuffer
All Implemented Interfaces:
ChannelDataStore, Cloneable, Serializable

public class ZeroBuffer
extends Object
implements ChannelDataStore, Serializable

This is used to create a zero-buffered object channel that never loses data.

Description

ZeroBuffer is an implementation of ChannelDataStore that yields the standard CSP semantics for a channel -- that is zero buffered with direct synchronisation between reader and writer. Unless specified otherwise, this is the default behaviour for channels. See the static create methods of One2OneChannel etc.

The getState method will return FULL if there is an output waiting on the channel and EMPTY if there is not.

Author:
P.D.Austin
See Also:
Buffer, OverWriteOldestBuffer, OverWritingBuffer, OverFlowingBuffer, InfiniteBuffer, One2OneChannel, Any2OneChannel, One2AnyChannel, Any2AnyChannel, Serialized Form

Fields inherited from interface jcsp.util.ChannelDataStore
EMPTY, FULL, NONEMPTYFULL
 
Constructor Summary
ZeroBuffer()
           
 
Method Summary
 Object clone()
          Returns a new (and EMPTY) ZeroBuffer with the same creation parameters as this one.
 Object get()
          Returns the Object from the ZeroBuffer.
 int getState()
          Returns the current state of the ZeroBuffer.
 void put(Object value)
          Puts a new Object into the ZeroBuffer.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ZeroBuffer

public ZeroBuffer()
Method Detail

get

public Object get()
Returns the Object from the ZeroBuffer.

Pre-condition: getState must not currently return EMPTY.

Specified by:
get in interface ChannelDataStore
Returns:
the Object from the ZeroBuffer

put

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

Pre-condition: getState must not currently return FULL.

Specified by:
put in interface ChannelDataStore
Parameters:
value - the Object to put into the ZeroBuffer

getState

public int getState()
Returns the current state of the ZeroBuffer.
Specified by:
getState in interface ChannelDataStore
Returns:
the current state of the ZeroBuffer (EMPTY or FULL)

clone

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

Note: Only the size and structure of the ZeroBuffer is cloned, not any stored data.

Specified by:
clone in interface ChannelDataStore
Overrides:
clone in class Object
Returns:
the cloned instance of this ZeroBuffer.

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.