EDU.oswego.cs.dl.util.concurrent
public abstract class SemaphoreControlledChannel extends Object implements BoundedChannel
Field Summary | |
---|---|
protected int | capacity_ |
protected Semaphore | putGuard_ |
protected Semaphore | takeGuard_ |
Constructor Summary | |
---|---|
SemaphoreControlledChannel(int capacity)
Create a channel with the given capacity and default
semaphore implementation | |
SemaphoreControlledChannel(int capacity, Class semaphoreClass)
Create a channel with the given capacity and
semaphore implementations instantiated from the supplied class |
Method Summary | |
---|---|
int | capacity() |
protected abstract Object | extract()
Internal mechanics of take.
|
protected abstract void | insert(Object x)
Internal mechanics of put.
|
boolean | offer(Object x, long msecs) |
Object | poll(long msecs) |
void | put(Object x) |
int | size()
Return the number of elements in the buffer.
|
Object | take() |
Throws: IllegalArgumentException if capacity less or equal to zero
Throws: IllegalArgumentException if capacity less or equal to zero. 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