public class Slot extends SemaphoreControlledChannel
Among other applications, Slots can be convenient in token-passing designs: Here. the Slot holds a some object serving as a token, that can be obtained and returned by various threads.
| Modifier and Type | Field and Description |
|---|---|
protected java.lang.Object |
item_
The slot
|
capacity_, putGuard_, takeGuard_| Constructor and Description |
|---|
Slot()
Create a new Slot using default Semaphore implementations
|
Slot(java.lang.Class semaphoreClass)
Create a buffer with the given capacity, using
the supplied Semaphore class for semaphores.
|
| Modifier and Type | Method and Description |
|---|---|
protected java.lang.Object |
extract()
Take item known to exist
|
protected void |
insert(java.lang.Object x)
Set the item in preparation for a take
|
java.lang.Object |
peek()
Return, but do not remove object at head of Channel,
or null if it is empty.
|
public Slot(java.lang.Class semaphoreClass)
throws java.lang.NoSuchMethodException,
java.lang.SecurityException,
java.lang.InstantiationException,
java.lang.IllegalAccessException,
java.lang.reflect.InvocationTargetException
java.lang.NoSuchMethodException - If class does not have constructor
that intializes permitsjava.lang.SecurityException - if constructor information
not accessiblejava.lang.InstantiationException - if semaphore class is abstractjava.lang.IllegalAccessException - if constructor cannot be calledjava.lang.reflect.InvocationTargetException - if semaphore constructor throws an
exceptionpublic Slot()
protected void insert(java.lang.Object x)
insert in class SemaphoreControlledChannelprotected java.lang.Object extract()
extract in class SemaphoreControlledChannelpublic java.lang.Object peek()
Channel