public class DijkstraSemaphore extends Object
| Constructor and Description |
|---|
DijkstraSemaphore(int pMaxCount)
Creates a Dijkstra semaphore with the specified max count and initial count set
to the max count (all resources released)
|
DijkstraSemaphore(int pMaxCount,
int pInitialCount)
Creates a Dijkstra semaphore with the specified max count and an initial count
of acquire() operations that are assumed to have already been performed.
|
| Modifier and Type | Method and Description |
|---|---|
void |
acquire()
If the count is non-zero, acquires a semaphore and decrements the count by 1,
otherwise blocks until a release() is executed by some other thread.
|
void |
acquireAll()
Tries to acquire all the semaphores thus bringing the count to zero.
|
void |
release()
Releases a previously acquires semaphore and increments the count by one.
|
void |
release(int pCount)
Same as release() except that the count is increased by pCount instead of 1.
|
void |
releaseAll()
Releases all semaphores setting the count to max count.
|
void |
starvationCheck()
This method blocks the calling thread until the count drops to zero.
|
boolean |
tryAcquire()
Non-blocking version of acquire().
|
public DijkstraSemaphore(int pMaxCount)
pMaxCount - is the max semaphores that can be acquiredpublic DijkstraSemaphore(int pMaxCount,
int pInitialCount)
pMaxCount - is the max semaphores that can be acquiredpInitialCount - is the current count (setting it to zero means all semaphores
have already been acquired). 0 <= pInitialCount <= pMaxCountpublic void acquire()
throws InterruptedException
InterruptedException - if the thread is interrupted when blockedtryAcquire(),
acquireAll()public boolean tryAcquire()
public void release()
release(int pCount),
releaseAll()public void release(int pCount)
pCount - is the amount by which the counter should be incrementedrelease()public void acquireAll()
throws InterruptedException
InterruptedException - if the thread is interrupted when blocked on this callacquire(),
releaseAll()public void releaseAll()
acquireAll()public void starvationCheck()
throws InterruptedException
InterruptedException - if the thread is interrupted while waitingMMBase 1.9-SNAPSHOT - ${javadoctimestamp}