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 Object |
item_
The slot
|
capacity_, putGuard_, takeGuard_| Constructor and Description |
|---|
Slot()
Create a new Slot using default Semaphore implementations
|
Slot(Class semaphoreClass)
Create a buffer with the given capacity, using
the supplied Semaphore class for semaphores.
|
| Modifier and Type | Method and Description |
|---|---|
protected Object |
extract()
Take item known to exist
|
protected void |
insert(Object x)
Set the item in preparation for a take
|
Object |
peek()
Return, but do not remove object at head of Channel,
or null if it is empty.
|
protected Object item_
public Slot(Class semaphoreClass) throws NoSuchMethodException, SecurityException, InstantiationException, IllegalAccessException, InvocationTargetException
NoSuchMethodException - If class does not have constructor
that intializes permitsSecurityException - if constructor information
not accessibleInstantiationException - if semaphore class is abstractIllegalAccessException - if constructor cannot be calledInvocationTargetException - if semaphore constructor throws an
exceptionpublic Slot()
protected void insert(Object x)
insert in class SemaphoreControlledChannelprotected Object extract()
extract in class SemaphoreControlledChannelCopyright © 2002-2017. All Rights Reserved.