Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

CReaper Class Reference

#include <CReaper.h>

List of all members.

Public Types

typedef list< CEvent * > CEventList
typedef list< CEvent
* >::iterator 
CEventListIterator

Public Methods

 CReaper ()
 Default constructor.

virtual ~CReaper ()
 Destructor.

CEventList getThreadOjbects () const
virtual void OnTimer ()
CEventListIterator begin ()
CEventListIterator end ()
int size ()

Static Public Methods

CReaper * getInstance ()
void Add (CEvent *pEvent)

Private Methods

CReaper & operator= (const CReaper &rhs)
 Assignment.

int operator== (const CReaper &rhs) const
 Comparison for equality.

int operator!= (const CReaper &rhs) const
 CReaper (const CReaper &rhs)
 Copy constructor.


Static Private Attributes

CEventList m_ThreadObjects
 //!< Threads being monitored.

CReaper * m_pInstance = 0


Detailed Description

CReaper is an object that operates on a single shared list of delete on exit CEvent derived threads. The problem to solve is that there are essentially two types of threads: The first type, can be deleted by whoever pulls the final state information from them. The second type, however usually don't have an attentive parent and therefore need some management subsystem to delete the thread object when the thread has finished executing. CReaper does this. Note that m_ThreadObjects is static so that any number of CReaper objects could be created (in practice only one is), but they'll all share the common list. Note as well that Add is static so that it is not necessary to have a CReaper object in hand to add an item to the list. List access is globally synchronized using the global mutex.

The CReaper is a singleton object as there's not sense in allowing multiple thread to reap the same list of objects.

Definition at line 330 of file CReaper.h.


Member Typedef Documentation

typedef list<CEvent*> CReaper::CEventList
 

Definition at line 333 of file CReaper.h.

Referenced by getThreadOjbects().

typedef list<CEvent*>::iterator CReaper::CEventListIterator
 

Definition at line 334 of file CReaper.h.

Referenced by OnTimer().


Constructor & Destructor Documentation

CReaper::CReaper  
 

Default constructor.

Default constructor. This is called when declarations of the form e.g.:

  • CReaper object; are performed.
  • Initialize the base class.
  • If the instance variable is not null, throw an exception, otherwise set it to this. (CDuplicateObjectException).
  • schedule us.

Definition at line 307 of file CReaper.cpp.

References m_pInstance, nTiming(), and sName().

Referenced by getInstance().

CReaper::~CReaper   [virtual]
 

Destructor.

Destructor:

Definition at line 325 of file CReaper.cpp.

CReaper::CReaper const CReaper &    rhs [private]
 

Copy constructor.


Member Function Documentation

void CReaper::Add CEvent *    pEvent [static]
 

Add a CEvent derived object to the list of delete on exit objects. We lock the synchronization mutex to be sure there is serialized access to the member data.

Parameters:
pEvent  - CEvent* [in] Pointer to the event to add. It is assumed the event is already running when it is added. If it is not, the reaper's next pass may destroy the object if it is not yet running.

Definition at line 341 of file CReaper.cpp.

References m_ThreadObjects.

CReaper::CEventListIterator CReaper::begin  
 

Returns an iterator to the first item in the event list.

Definition at line 383 of file CReaper.cpp.

References m_ThreadObjects.

Referenced by OnTimer().

CReaper::CEventListIterator CReaper::end  
 

Returns an end of iteration flag iterator.

Note:
Dereferencing this iterator is invalid.

Definition at line 393 of file CReaper.cpp.

References m_ThreadObjects.

Referenced by OnTimer().

CReaper * CReaper::getInstance   [static]
 

Get the singleton instance of the reaper. Note that if the instance has not yet been made, it will be here.

Definition at line 410 of file CReaper.cpp.

References CReaper(), and m_pInstance.

Referenced by CReadoutMain::operator()().

CEventList CReaper::getThreadOjbects   const [inline]
 

Definition at line 354 of file CReaper.h.

References CEventList, and m_ThreadObjects.

void CReaper::OnTimer   [virtual]
 

Called periodically to scan the list of CEvent delete on exit objects.

  • For each object in m_ThreadObjects
  • If the thread's active flag is clear, join the thread.
  • Once the join indicates that the thread has properly exited, delete the thread object.
  • Remvoe deleted objects from m_ThreadObjects
Note:
If during iteration the thing pointed to by the iterator is removed from the container, the iterator becomes invalid and it is necessary to restart iteration.

Definition at line 364 of file CReaper.cpp.

References begin(), CEventListIterator, end(), and m_ThreadObjects.

int CReaper::operator!= const CReaper &    rhs const [private]
 

CReaper& CReaper::operator= const CReaper &    rhs [private]
 

Assignment.

int CReaper::operator== const CReaper &    rhs const [private]
 

Comparison for equality.

int CReaper::size  
 

Returns the number of entries in the event list.

Definition at line 401 of file CReaper.cpp.

References m_ThreadObjects.


Member Data Documentation

CReaper * CReaper::m_pInstance = 0 [static, private]
 

Definition at line 295 of file CReaper.cpp.

Referenced by CReaper(), and getInstance().

CReaper::CEventList CReaper::m_ThreadObjects [static, private]
 

//!< Threads being monitored.

Definition at line 294 of file CReaper.cpp.

Referenced by Add(), begin(), end(), getThreadOjbects(), OnTimer(), and size().


The documentation for this class was generated from the following files:
Generated on Fri Nov 8 13:37:21 2002 for Event Readout system. by doxygen1.2.16