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

CTriggerThread Class Reference

List of all members.

Public Methods

 CTriggerThread (CExperiment *pExp, CTrigger *pTrig)
 Construct a trigger thread object.

void Start ()
 Start trigger thread.

void Stop ()

Protected Methods

virtual int operator() (int argc, char **argv)
 Entry point for thread.. just calls MainLoop(), and returns 0.

virtual void MainLoop ()

Private Attributes

CExperimentm_pExperiment
 Points to our experiment object.

CTriggerm_pTrigger
 Points to the trigger check object.

bool m_Exiting
 True if asked to exit (stop called).

DAQThreadId m_Id
 Our thread ID if running.

unsigned int m_msHoldTime
 ms to hold the global mutex.

unsigned int m_nTriggerdwell
 triggers betweeen time polls.


Detailed Description

>>>LOCAL CLASS TO CEXPERIMENT<<< Encapsulates the thread which checks for triggers. This is a polling thread. Assumption is that the caller knows what it's doing and does not double start a thread!!.

Definition at line 374 of file CExperiment.cpp.


Constructor & Destructor Documentation

CTriggerThread::CTriggerThread CExperiment   pExp,
CTrigger   pTrig
 

Construct a trigger thread object.

Definition at line 393 of file CExperiment.cpp.

References nTriggerDwellTime, and nTriggersPerPoll.


Member Function Documentation

void CTriggerThread::MainLoop   [protected, virtual]
 

Main loop for trigger thread: The balancing act that's done in this loop is to keep trigger response latency low while not starving other threads such as the clock or interactive threads of execution.

  • Latency is minimized by holding the application serialization mutex, but holding that forever starves other application threads, so roughly every m_msHoldTime ms, the mutex is released and then re-attached (if there are people waiting for the mutex, they'll get to execute, and we'll go to the tail of the queue).
  • gettimeofday(2) requires execution time, and could increase trigger response latency. Therefore, the time we've held the application serialization mutex is only measured if either: # We have checked for triggers 500 times # We have processed m_nTriggerdwell event triggers.
The assumption here is that triggers take 100's of usec to process. At every mutex release, m_Exiting is checked, and if set, we return to our caller who is responsible for exiting our thread.

Definition at line 464 of file CExperiment.cpp.

References m_Exiting, m_msHoldTime, m_nTriggerdwell, m_pExperiment, MILISECOND, CExperiment::ReadEvent(), and SECOND.

Referenced by operator()().

int CTriggerThread::operator() int    argc,
char **    argv
[protected, virtual]
 

Entry point for thread.. just calls MainLoop(), and returns 0.

Definition at line 437 of file CExperiment.cpp.

References MainLoop().

void CTriggerThread::Start  
 

Start trigger thread.

Definition at line 402 of file CExperiment.cpp.

References m_Exiting, and m_Id.

Referenced by CExperiment::StartTrigger().

void CTriggerThread::Stop  
 

Schedule stop of trigger thread.

Note:
This function assumes the calling thread is not the trigger thread and that the caller owns the global serialization mutex (both reasonable assumptions).

Definition at line 413 of file CExperiment.cpp.

References m_Exiting, and m_Id.

Referenced by CExperiment::StopTrigger().


Member Data Documentation

bool CTriggerThread::m_Exiting [private]
 

True if asked to exit (stop called).

Definition at line 378 of file CExperiment.cpp.

Referenced by MainLoop(), Start(), and Stop().

DAQThreadId CTriggerThread::m_Id [private]
 

Our thread ID if running.

Definition at line 379 of file CExperiment.cpp.

Referenced by Start(), and Stop().

unsigned int CTriggerThread::m_msHoldTime [private]
 

ms to hold the global mutex.

Definition at line 380 of file CExperiment.cpp.

Referenced by MainLoop().

unsigned int CTriggerThread::m_nTriggerdwell [private]
 

triggers betweeen time polls.

Definition at line 381 of file CExperiment.cpp.

Referenced by MainLoop().

CExperiment* CTriggerThread::m_pExperiment [private]
 

Points to our experiment object.

Definition at line 376 of file CExperiment.cpp.

Referenced by MainLoop().

CTrigger* CTriggerThread::m_pTrigger [private]
 

Points to the trigger check object.

Definition at line 377 of file CExperiment.cpp.


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