public class OverWriteOldestBufferInt
This is used to create a buffered integer channel that always accepts input, overwriting its oldest data if full.
The getState method returns EMPTY or NONEMPTYFULL, but never FULL.
Constructor and description |
---|
OverWriteOldestBufferInt
(int size) Construct a new OverWriteOldestBufferInt with the specified size. |
Type | Name and description |
---|---|
Object |
clone() Returns a new (and EMPTY) OverWriteOldestBufferInt with the same creation parameters as this one. |
void |
endGet() See startGet() for a description of the semantics of this method. |
int |
get() Returns the oldest int from the OverWriteOldestBufferInt and removes it. |
int |
getState() Returns the current state of the OverWriteOldestBufferInt. |
void |
put(int value) Puts a new int into the OverWriteOldestBufferInt. |
void |
removeAll() |
int |
startGet() Begins an extended rendezvous by the reader. |
Construct a new OverWriteOldestBufferInt with the specified size.
size
- the number of ints the OverWriteOldestBufferInt can store.Returns a new (and EMPTY) OverWriteOldestBufferInt with the same creation parameters as this one.
Note: Only the size and structure of the OverWriteOldestBufferInt is cloned, not any stored data.
See startGet() for a description of the semantics of this method.
Returns the oldest int from the OverWriteOldestBufferInt and removes it.
Pre-condition: getState must not currently return EMPTY.
Returns the current state of the OverWriteOldestBufferInt.
Puts a new int into the OverWriteOldestBufferInt.
If OverWriteOldestBufferInt is full, the oldest item left unread in the buffer will be overwritten.
value
- the int to put into the OverWriteOldestBufferIntBegins an extended rendezvous by the reader. The semantics of an extended rendezvous on an overwrite-oldest buffer are slightly complicated, but hopefully intuitive. When a reader begins an extended rendezvous, the oldest value is returned from the buffer (as it would be for a call to get()). While an extended rendezvous is ongoing, the writer may (repeatedly) write to the buffer, without ever blocking. When the reader finishes an extended rendezvous, the following options are possible:
JCSP for Java 1.8 generated 14-10-2016 by Jon Kerridge, Edinburgh Napier University - j dot kerridge at napier dot ac dot uk