EDU.oswego.cs.dl.util.concurrent
Class Slot
- BoundedChannel, Channel, Puttable, Takable
A one-slot buffer, using semaphores to control access.
Slots are usually more efficient and controllable than using other
bounded buffers implementations with capacity of 1.
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.
[
Introduction to this package. ]
protected Object | item_ - The slot *
|
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.
|
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.
|
item_
protected Object item_
The slot *
Slot
public Slot()
Create a new Slot using default Semaphore implementations
Slot
public Slot(Class semaphoreClass)
throws NoSuchMethodException,
SecurityException,
InstantiationException,
IllegalAccessException,
InvocationTargetException
Create a buffer with the given capacity, using
the supplied Semaphore class for semaphores.
peek
public Object peek()
Return, but do not remove object at head of Channel,
or null if it is empty.
- peek in interface Channel