|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.newisys.dv.Semaphore
public final class Semaphore
Implements a counting semaphore using a SimulationManager.
| Constructor Summary | |
|---|---|
Semaphore(SimulationManager simManager,
int permits)
Constructs a new semaphore with a generated name and the given initial permit count using the given simulation manager. |
|
Semaphore(SimulationManager simManager,
String name,
int permits)
Constructs a new semaphore with the given name and initial permit count using the given simulation manager. |
|
| Method Summary | |
|---|---|
void |
acquire()
Acquire one permit from this semaphore, waiting until one is available if necessary. |
void |
acquire(int permits)
Acquires the given number of permits from this semaphore, waiting until they are available if necessary. |
boolean |
attempt()
Attempts to acquire one permit from this semaphore. |
boolean |
attempt(int permits)
Attempts to acquire the given number of permits from this semaphore. |
void |
release()
Releases one permit for this semaphore, allowing it to be acquired by other threads. |
void |
release(int permits)
Releases the given number of permits for this semaphore, allowing them to be acquired by other threads. |
String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public Semaphore(SimulationManager simManager,
String name,
int permits)
simManager - the simulation manager coordinating this semaphorename - the name of this semaphore (for debugging purposes)permits - the number of times acquire() will succeed before
release() is called
public Semaphore(SimulationManager simManager,
int permits)
simManager - the simulation manager coordinating this semaphorepermits - the number of times acquire() will succeed before
release() is called| Method Detail |
|---|
public void acquire()
public void acquire(int permits)
permits - the number of permits to acquirepublic boolean attempt()
public boolean attempt(int permits)
permits - the number of permits to acquire
public void release()
public void release(int permits)
permits - the number of permits to release
IllegalArgumentException - if permits is < 0public String toString()
toString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||