Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

alma::ACS::MasterComponentImpl::StateChangeSemaphore Class Reference

Inheritance diagram for alma::ACS::MasterComponentImpl::StateChangeSemaphore:

Inheritance graph
[legend]
List of all members.

Public Member Functions

 StateChangeSemaphore (Logger logger)
synchronized void waitForStateChanges (int count) throws InterruptedException
synchronized void reset ()

Protected Member Functions

synchronized void stateChangedNotify ()

Private Attributes

volatile int notifCount = 0
volatile int minCount
final Logger logger

Detailed Description

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.

Author:
hsommer created Apr 30, 2004 9:50:34 AM


Constructor & Destructor Documentation

alma::ACS::MasterComponentImpl::StateChangeSemaphore::StateChangeSemaphore Logger  logger  )  [inline]
 


Member Function Documentation

synchronized void alma::ACS::MasterComponentImpl::StateChangeSemaphore::reset  )  [inline]
 

Resets the state change notification count. Must be called prior to sending a state event.

synchronized void alma::ACS::MasterComponentImpl::StateChangeSemaphore::stateChangedNotify  )  [inline, 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 [inline]
 

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.

Parameters:
count number of state change notifications that must be received since last call to reset() so that this call will return
Exceptions:
InterruptedException 


Member Data Documentation

final Logger alma::ACS::MasterComponentImpl::StateChangeSemaphore::logger [private]
 

volatile int alma::ACS::MasterComponentImpl::StateChangeSemaphore::minCount [private]
 

volatile int alma::ACS::MasterComponentImpl::StateChangeSemaphore::notifCount = 0 [private]
 


The documentation for this class was generated from the following file:
Generated on Thu Apr 30 02:54:04 2009 for ACS Java API by doxygen 1.3.8