acsalarm::AlarmSourceThread − |
#include <AlarmSourceThread.h> Inherits ACS::Thread. |
Public Member Functions |
AlarmSourceThread () |
virtual ~AlarmSourceThread () |
void runLoop () |
bool registerForUpdating (AlarmSource *src) |
bool unregisterFromUpdating (AlarmSource *src) |
Private Attributes |
ACE_Recursive_Thread_Mutex m_mutex |
std::set< AlarmSource * > m_alarmSources |
AlarmSource and AlarmsMap require to be updated in a loop, this was initially done by one thread for each object that means 2 more threads for each component. Together with other strategies, we decided to have only one thread for updating all the AlarmSources running in a container. Each AlarmSource object that wants to be updated, must register itself for updating and deregister before being deleted. The AlarmSourceThread does not take ownership of the AlarmSource pointers passed to the register and deregister methods. This means that the memory management of such objects is responsibility of the caller. In particular the AlarmSource object a pointer refers to must be instantiated before being passed to registerForUpdating(..) and deleted only after being deregistered with unregisterFromUpdating(...). The pointers passed to registerForUpdating(..) and to unregisterFromUpdating(..) can’t be NULL. The fail-fast approach is used for failures in runLoop() ( See also: |
AlarmSourceThread::runLoop()) |
The thread runs in a loop regardless of how many AlarmSoource objects it updates. This means that if there are many objects the thread does not update them with a precise time interval and the AlarmSource must take that in account i.e. rely on the actual time instead of, for example, counting the iterations. |
acsalarm::AlarmSourceThread::AlarmSourceThread () Constructor |
virtual acsalarm::AlarmSourceThread::~AlarmSourceThread () [virtual] Destructor |
bool acsalarm::AlarmSourceThread::registerForUpdating (AlarmSource * src) Register the AlarmSource for updating |
Parameters: |
src The not NULL AlarmSource to be updated |
Returns: |
true if the element has been effectively registered or false otherwise |
void acsalarm::AlarmSourceThread::runLoop () [virtual] The thread to update the AlrmSource objects at regular intervals. |
runLoop iterates through all the registered AlarmSource’s and invoke AlarmSource::update(). The AlarmSource::update() method is called in a try/catch block to detect problems in the AlarmSource’s. In this case we log a message and throw the exception to a higher level (fail-fast). If such an error happens then we are loosing an important functionality (the ability to set/clear alarms) and we want to know it immediately and fix. See also: |
ACS::Thread |
Reimplemented from ACS::Thread. |
bool acsalarm::AlarmSourceThread::unregisterFromUpdating (AlarmSource * src) Unregister the AlarmSource from the updating thread. |
Parameters: |
src The not NULL AlarmSource to be updated |
Returns: |
true if the element has been effectively unregistered or false otherwise |
std::set<AlarmSource*> acsalarm::AlarmSourceThread::m_alarmSources [private] |
ACE_Recursive_Thread_Mutex acsalarm::AlarmSourceThread::m_mutex [private] |
Generated automatically by Doxygen for ACS-2015.2 C++ API from the source code. |