EDU.oswego.cs.dl.util.concurrent

Class Slot

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. ]

Field Summary
protected Objectitem_
The slot *
Constructor Summary
Slot(Class semaphoreClass)
Create a buffer with the given capacity, using the supplied Semaphore class for semaphores.
Slot()
Create a new Slot using default Semaphore implementations
Method Summary
protected Objectextract()
Take item known to exist *
protected voidinsert(Object x)
Set the item in preparation for a take *
Objectpeek()

Field Detail

item_

protected Object item_
The slot *

Constructor Detail

Slot

public Slot(Class 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

Slot

public Slot()
Create a new Slot using default Semaphore implementations

Method Detail

extract

protected Object extract()
Take item known to exist *

insert

protected void insert(Object x)
Set the item in preparation for a take *

peek

public Object peek()