CFEL - ASG Software Suite  2.5.0
CASS
Public Types | Public Member Functions | Private Attributes | List of all members
cass::Worker Class Reference

The worker thread. More...

#include <worker.h>

+ Inheritance diagram for cass::Worker:
+ Collaboration diagram for cass::Worker:

Public Types

typedef std::tr1::shared_ptr< Workershared_pointer
 a shared pointer of this More...
 
- Public Types inherited from lmf::PausableThread
enum  status_t { running, paused, notstarted }
 enum describing the internal status of the thread More...
 
enum  control_t { _run, _quit, _pause }
 enum describing the control status of the thread More...
 
enum  exception_t {
  NO_EXCEPTION, INVALID_ARGUMENT_EXCEPTION, RUNTIME_ERROR_EXCEPTION, OUT_OF_RANGE_EXCEPTION,
  LOGIC_ERROR_EXCEPTION, STANDART_EXCEPTION, UNKNOWN_EXCEPTION
}
 enum describing which exception was thrown More...
 

Public Member Functions

 Worker (RingBuffer< CASSEvent > &rb, Ratemeter &ratemeter, QObject *parent=0)
 constructor. More...
 
void runthis ()
 start the thread. More...
 
- Public Member Functions inherited from lmf::PausableThread
 PausableThread (control_t control=_run, QObject *parent=0)
 constructor More...
 
virtual ~PausableThread ()
 destructor More...
 
void run ()
 run the thread More...
 
void pause (bool block=false)
 pause the thread More...
 
void waitUntilPaused ()
 waits until thread is paused More...
 
void resume ()
 resume the thread More...
 
status_t status () const
 return the current status of the thread More...
 
bool shouldQuit () const
 query whether this thread is told to quit More...
 
void rethrowException () const
 rethrow the thrown exception More...
 
exception_t exceptionThrown () const
 
- Public Member Functions inherited from QThread
 QThread (QObject *parent=0)
 
 currentThread ()
 
 HANDLE QThread::currentThreadId()
 
 exec ()
 
 exit (int returnCode=0)
 
 finished ()
 
 idealThreadCount ()
 
 isFinished ()
 
 isRunning ()
 
 msleep (unsigned long msecs)
 
 priority ()
 
 quit ()
 
 run ()
 
 setPriority (Priority priority)
 
 setStackSize (uint stackSize)
 
 setTerminationEnabled (bool enabled=true)
 
 sleep (unsigned long secs)
 
 stackSize ()
 
 start (Priority priority=InheritPriority)
 
 started ()
 
 terminate ()
 
 terminated ()
 
 usleep (unsigned long usecs)
 
 wait (unsigned long time=ULONG_MAX)
 
 yieldCurrentThread ()
 

Private Attributes

RingBuffer< CASSEvent > & _ringbuffer
 the ringbuffer More...
 
ProcessorManager_process
 the processors More...
 
Ratemeter_ratemeter
 the ratemeter to measure the analysis rate More...
 

Additional Inherited Members

- Public Slots inherited from lmf::PausableThread
virtual void end ()
 tell the thread to quit More...
 
- Protected Member Functions inherited from lmf::PausableThread
void pausePoint ()
 point where the thread will be paused More...
 
- Protected Attributes inherited from lmf::PausableThread
QMutex _pauseMutex
 mutex to wait on until thread is paused More...
 
QWaitCondition _pauseCondition
 wait condition to wait on until thread is resumed More...
 
QWaitCondition _waitUntilPausedCondition
 wait condition to wait unitl thread is paused More...
 
status_t _status
 the internal status of the thread More...
 
control_t _control
 the internal control status of the thread More...
 
size_t _pausecount
 a counter how many threads have pause this thread More...
 
exception_t _exception_thrown
 flag to show that general exception was thrown More...
 
std::invalid_argument _invarg_excep
 the invalid arguemnt exception thrown More...
 
std::runtime_error _runt_excep
 the invalid arguemnt exception thrown More...
 
std::out_of_range _outrange_excep
 the invalid arguemnt exception thrown More...
 
std::logic_error _logic_excep
 the invalid arguemnt exception thrown More...
 

Detailed Description

The worker thread.

The thread will do the following tasks in a loop:

Author
Lutz Foucar

Definition at line 40 of file worker.h.

Member Typedef Documentation

typedef std::tr1::shared_ptr<Worker> cass::Worker::shared_pointer

a shared pointer of this

Definition at line 45 of file worker.h.

Constructor & Destructor Documentation

Worker::Worker ( RingBuffer< CASSEvent > &  rb,
Ratemeter ratemeter,
QObject parent = 0 
)

constructor.

Parameters
rbthe rinbguffer we get the events from
ratemeterthe ratemeter object to measure the rate
parentthe qt parent of this object

Definition at line 23 of file worker.cpp.

Member Function Documentation

void Worker::runthis ( )
virtual

start the thread.

While the thread has not been quitted do retrieve a cassevent from the ringbuffer, but with a timeout. If we got a new event from the ringbuffer put it into the processing chain. Then put it back to the ringbuffer for new refilling and increase the counter of the ratemeter. Before processing double check if the event has a correct id

ensure that one has retrieved a valid event and that the id is non zero number

Note
we need to check the element id in here, because if it is done in the outer if statement (as before) a valid ringbuffer element would never be returned to the buffer, as this only happens within the true if clause.

Implements lmf::PausableThread.

Definition at line 32 of file worker.cpp.

References lmf::PausableThread::_control, _process, lmf::PausableThread::_quit, _ratemeter, _ringbuffer, lmf::PausableThread::_status, cass::Ratemeter::count(), lmf::PausableThread::pausePoint(), and lmf::PausableThread::running.

Member Data Documentation

ProcessorManager& cass::Worker::_process
private

the processors

Definition at line 73 of file worker.h.

Referenced by runthis().

Ratemeter& cass::Worker::_ratemeter
private

the ratemeter to measure the analysis rate

Definition at line 76 of file worker.h.

Referenced by runthis().

RingBuffer<CASSEvent>& cass::Worker::_ringbuffer
private

the ringbuffer

Definition at line 70 of file worker.h.

Referenced by runthis().


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