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

Inheritance diagram for alma::ACS::MasterComponentImpl::StateChangeSemaphore:
Inheritance graph
[legend]
Collaboration diagram for alma::ACS::MasterComponentImpl::StateChangeSemaphore:
Collaboration 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]
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.

References logger, minCount, and notifCount.

Referenced by alma::ACS::MasterComponentImpl::StateChangeListener::MyStateChangeSemaphore::externalStateChangedNotify(), and alma::ACS::MasterComponentImpl::statemachine::StateMachineTest::MyStateChangeSemaphore::stateChangedNotify().

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 

References logger, minCount, and notifCount.

Referenced by alma::ACS::MasterComponentImpl::MasterComponentTest::_testEventSync(), alma::ACS::MasterComponentImpl::statemachine::StateMachineTest::testActionException(), alma::ACS::SpecialTestMasterComponentImpl::SpecialTestMasterComponentTest::testHealthySubsystemLifecycle(), alma::ACS::MasterComponentImpl::statemachine::StateMachineTest::testIllegalEvent(), alma::ACS::MasterComponentImpl::statemachine::StateMachineTest::testLegalLifecycle(), and alma::ACS::MasterComponentImpl::statemachine::StateMachineTest::testReentryToCompositeState().


Member Data Documentation


The documentation for this class was generated from the following file:

Generated by  doxygen 1.6.2