|
IBM Branch Transformation Toolkit Javadoc | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.ibm.dse.base.Semaphore
This class provides a semaphore with timeOut option. SignalOn or signalOnAll must be used depending if processes are initiated one at a time or all at once. SignalOn method works with a signals counter, which is important to know if there are signals to be processed using hasSignals method. Then, reset signal does not make any sense in this case and the use of waitOnAndResetSignal methods must be forbbiden to ensure a good use of the semaphore in the application. Also the application must be consistent using the different options of the wait methods, so it is advised to be aware of merge waits with different values of waitEvenIfSignalAlreadyNotified parameter. SignalOnAll always must be used with waitOnAndResetSignal methods in order to grant consistency with the signals counter because in this case it is not needed.
Constructor Summary | |
---|---|
Semaphore()
This constructor creates a Semaphore object. |
Method Summary | |
---|---|
void |
clearSignal()
Clears signalsCounter property. |
boolean |
hasSignals()
Returns true if a signal has already been notified when a process wants to enter the semaphore. |
boolean |
hasTimedOut()
Returns true if a thread has been awakened by a time out. |
void |
signalOn()
Wakes up a thread that is waiting on the Semaphore. |
void |
signalOnAll()
Wakes up all threads that are waiting on the Semaphore. |
void |
waitOn()
Unless a signal has already been notified, this method holds the process indefinitely until the Semaphore receives a signal. |
void |
waitOn(boolean waitEvenIfSignalAlreadyNotified,
boolean resetSignal)
Holds the process until the Semaphore receives the signal. |
void |
waitOn(long timeout)
Unless a signal has already been notified, this method holds the process until the Semaphore receives a signal or until the timeout is reached. |
void |
waitOn(long timeout,
boolean waitEvenIfSignalAlreadyNotified,
boolean resetSignal)
Holds the process until the Semaphore receives the signal or until the timeout is reached. |
void |
waitOnAndResetSignal()
Unless a signal has already been notified, this method holds the process until the Semaphore receives a signal. |
void |
waitOnAndResetSignal(long timeout)
Unless a signal has already been notified, this method holds the process until the Semaphore receives a signal or until the timeout is reached. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public Semaphore()
Method Detail |
public void clearSignal()
public boolean hasSignals()
public boolean hasTimedOut()
public void signalOn()
public void signalOnAll()
public void waitOn()
public void waitOn(long timeout)
timeout
- long - The maximum time to wait in millisecondspublic void waitOn(long timeout, boolean waitEvenIfSignalAlreadyNotified, boolean resetSignal)
timeout
- long - The maximum time to wait in millisecondswaitEvenIfSignalAlreadyNotified
- - Boolean allows to choose to wait or no if a signal
has already been notifiedresetSignal
- - Boolean allows to reset signalAlreadyNotified property.public void waitOn(boolean waitEvenIfSignalAlreadyNotified, boolean resetSignal)
public void waitOnAndResetSignal()
public void waitOnAndResetSignal(long timeout)
timeout
- long - The maximum time to wait in milliseconds
|
IBM Branch Transformation Toolkit Javadoc | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |