EDU.oswego.cs.dl.util.concurrent
public class: Slot [javadoc |
source]
java.lang.Object
EDU.oswego.cs.dl.util.concurrent.SemaphoreControlledChannel
EDU.oswego.cs.dl.util.concurrent.Slot
All Implemented Interfaces:
BoundedChannel
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. ]
Field Summary |
---|
protected Object | item_ | The slot * |
Constructor: |
public Slot() {
super(1);
}
Create a new Slot using default Semaphore implementations |
public Slot(Class semaphoreClass) throws NoSuchMethodException, SecurityException, InstantiationException, IllegalAccessException, InvocationTargetException {
super(1, semaphoreClass);
}
Create a buffer with the given capacity, using
the supplied Semaphore class for semaphores. Throws:
NoSuchMethodException - If class does not have constructor
that intializes permits
SecurityException - if constructor information
not accessible
InstantiationException - if semaphore class is abstract
IllegalAccessException - if constructor cannot be called
InvocationTargetException - if semaphore constructor throws an
exception
*
- exception:
NoSuchMethodException - If class does not have constructor
that intializes permits
- exception:
SecurityException - if constructor information
not accessible
- exception:
InstantiationException - if semaphore class is abstract
- exception:
IllegalAccessException - if constructor cannot be called
- exception:
InvocationTargetException - if semaphore constructor throws an
exception
*
|
Methods from java.lang.Object: |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method from EDU.oswego.cs.dl.util.concurrent.Slot Detail: |
protected synchronized Object extract() {
Object x = item_;
item_ = null;
return x;
}
Take item known to exist * |
protected synchronized void insert(Object x) {
item_ = x;
}
Set the item in preparation for a take |
public synchronized Object peek() {
return item_;
}
|