Inherited by alma.ACS.MasterComponentImpl.StateChangeListener.MyStateChangeSemaphore.
Public Member Functions | |
StateChangeSemaphore (Logger logger) | |
synchronized void | waitForStateChanges (int count) throws InterruptedException |
synchronized void | reset () |
Protected Member Functions | |
synchronized void | stateChangedNotify () |
Helper class that allows to synchronize the sending of events with the state changes due to previous events. Note that state changes occur asynchronously when triggered by activity states.
This class is abstracted from concrete state change notification APIs so that subclasses can be implemented as such listeners; they must call stateChangedNotify() upon notification by the state machine.
alma.ACS.MasterComponentImpl.StateChangeSemaphore.StateChangeSemaphore | ( | Logger | logger | ) |
synchronized void alma.ACS.MasterComponentImpl.StateChangeSemaphore.reset | ( | ) |
Resets the state change notification count. Must be called prior to sending a state event.
synchronized void alma.ACS.MasterComponentImpl.StateChangeSemaphore.stateChangedNotify | ( | ) | [protected] |
To be called from state change listener method of subclass.
This call is expected to come from a different thread than the one that calls waitForStateChanges
. Both methods are synchronized, but there will not be a deadlock, since waitForStateChanges
yields ownership of the monitor when calling wait.
synchronized void alma.ACS.MasterComponentImpl.StateChangeSemaphore.waitForStateChanges | ( | int | count | ) | throws InterruptedException |
Blocks until the specified number of state change notifications have been received since last call to reset().
Does not block at all if at least count
state change notifications have been received since the last call to reset
. Otherwise only blocks until the missing number of notifications has arrived. Before returning, this method subtracts count
from the internal counter for state change notifications, which allows a client to catch up with fast firing event notifications by calling this method several times.
Note that the "synchronized" modifier is required in order for the client thread to obtain ownership of this semaphore (i.e. its monitor), without which the thread synchronization would not work. See Object#notify() for an explanation.
count | number of state change notifications that must be received since last call to reset() so that this call will return |
InterruptedException |