edu.oswego.cs.dl.util.concurrent
Class Slot
java.lang.Object
|
+--edu.oswego.cs.dl.util.concurrent.SemaphoreControlledChannel
|
+--edu.oswego.cs.dl.util.concurrent.Slot
- All Implemented Interfaces:
- BoundedChannel, Channel, Puttable, Takable
- public class Slot
- extends SemaphoreControlledChannel
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. ]
Constructor Summary |
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. |
Method Summary |
Object |
peek()
Return, but do not remove object at head of Channel,
or null if it is empty. |
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.
- Throws:
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
exception
Slot
public Slot()
- Create a new Slot using default Semaphore implementations
peek
public Object peek()
- Description copied from interface:
Channel
- Return, but do not remove object at head of Channel,
or null if it is empty.
Submit a bug or feature. Check the Colt home page for the latest news.