public class OverWritingBuffer
This is used to create a buffered object channel that always accepts input, overwriting its last entered data if full.
The getState method returns EMPTY or NONEMPTYFULL, but never FULL.
Constructor and description |
---|
OverWritingBuffer
(int size) Construct a new OverWritingBuffer with the specified size. |
Type | Name and description |
---|---|
Object |
clone() Returns a new (and EMPTY) OverWritingBuffer with the same creation parameters as this one. |
void |
endGet() See startGet() for a description of the semantics of this method. |
Object |
get() Returns the oldest Object from the OverWritingBuffer and removes it. |
int |
getState() Returns the current state of the OverWritingBuffer. |
void |
put(Object value) Puts a new Object into the OverWritingBuffer. |
void |
removeAll() |
Object |
startGet() Begins an extended rendezvous by the reader. |
Construct a new OverWritingBuffer with the specified size.
size
- the number of Objects the OverWritingBuffer can store.Returns a new (and EMPTY) OverWritingBuffer with the same creation parameters as this one.
Note: Only the size and structure of the OverWritingBuffer is cloned, not any stored data.
See startGet() for a description of the semantics of this method.
Returns the oldest Object from the OverWritingBuffer and removes it.
Pre-condition: getState must not currently return EMPTY.
Returns the current state of the OverWritingBuffer.
Puts a new Object into the OverWritingBuffer.
If OverWritingBuffer is full, the last item previously put into the buffer will be overwritten.
value
- the Object to put into the OverWritingBufferBegins an extended rendezvous by the reader. The semantics of an extended rendezvous on an overwrite-newest buffer are slightly complicated, but hopefully intuitive. If the buffer is of size 2 or larger, the semantics are as follows. Beginning an extended rendezvous will return the oldest value in the buffer, but not remove it. If the writer writes to the buffer during the rendezvous, it will grow the buffer and end up overwriting the newest value as normal. At the end of the extended rendezvous, the oldest value is removed. If the buffer is of size 1, the semantics are identical to those of an OverWriteOldestBuffer. For a complete description, refer to the documentation for the OverWriteOldestBuffer.startGet() method.
JCSP for Java 1.8 generated 14-10-2016 by Jon Kerridge, Edinburgh Napier University - j dot kerridge at napier dot ac dot uk