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

Worker Thread Handler. More...

#include <worker.h>

+ Collaboration diagram for cass::Workers:

Public Types

typedef std::tr1::shared_ptr< Workersshared_pointer
 a shared pointer of this class More...
 

Public Member Functions

void start ()
 starts the threads More...
 
void pause ()
 pause the threads. More...
 
void resume ()
 resumes the threads More...
 
void end ()
 will set the flags to end the threads More...
 
bool running () const
 check if all workers are still running More...
 
void rethrowException ()
 rethrow the exceptions thrown in the workers More...
 

Static Public Member Functions

static shared_pointer instance (RingBuffer< CASSEvent > &rb, Ratemeter &ratemeter, QObject *parent=0)
 create and return an instance of this singleton More...
 
static shared_pointer::element_type & reference ()
 return a reference to the instance itselve if it exists More...
 

Public Attributes

QMutex lock
 a lock to be used by functions that are using this worker More...
 

Private Member Functions

 Workers (RingBuffer< CASSEvent > &rb, Ratemeter &ratemeter, QObject *parent=0)
 constructor. More...
 

Private Attributes

std::vector< Worker::shared_pointer_workers
 container of workers More...
 
RingBuffer< CASSEvent > & _rb
 the ringbuffer More...
 

Static Private Attributes

static shared_pointer _instance
 the instance of this class More...
 
static QMutex _mutex
 mutex to protect the creation of the signelton More...
 

Detailed Description

Worker Thread Handler.

a class that will handle the requested amount of workers threads. The amount of threads can be set in cass.h via parameters

See also
NbrOfWorkers.
Author
Lutz Foucar

Definition at line 93 of file worker.h.

Member Typedef Documentation

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

a shared pointer of this class

Definition at line 97 of file worker.h.

Constructor & Destructor Documentation

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

constructor.

will create the requested amount of threads. and calls the load settings member of one of them.

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

Definition at line 87 of file worker.cpp.

References _workers.

Referenced by instance().

Member Function Documentation

void Workers::end ( )

will set the flags to end the threads

Will call the end() member of all workers. Then waits until all workers are finished. After this the aboutToQuit member of the processor and the Analyzer are notified.

function is not reentrant. One needs to use the _lock mutex to prevent simultanious calling of this function.

Definition at line 117 of file worker.cpp.

References _workers, and cass::ProcessorManager::instance().

Workers::shared_pointer Workers::instance ( RingBuffer< CASSEvent > &  rb,
Ratemeter ratemeter,
QObject parent = 0 
)
static

create and return an instance of this singleton

when the instance has not yet been created, call the constructor otherwise just return the instance.

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

Definition at line 66 of file worker.cpp.

References _instance, _mutex, lock, and Workers().

void Workers::pause ( )

pause the threads.

Blocks until all threads are paused

function is not reentrant. One needs to use the _lock mutex to prevent simultanious calling of this function.

Definition at line 103 of file worker.cpp.

References _workers.

Workers::shared_pointer::element_type & Workers::reference ( )
static

return a reference to the instance itselve if it exists

Definition at line 76 of file worker.cpp.

References _instance, _mutex, and lock.

void Workers::resume ( )

resumes the threads

function is not reentrant. One needs to use the _lock mutex to prevent simultanious calling of this function.

Definition at line 111 of file worker.cpp.

References _workers.

void Workers::rethrowException ( )

rethrow the exceptions thrown in the workers

Definition at line 126 of file worker.cpp.

References _workers.

bool Workers::running ( ) const

check if all workers are still running

Returns
false if one of the workers is not running anymore

Definition at line 132 of file worker.cpp.

References _workers.

void Workers::start ( )

starts the threads

function is not reentrant. One needs to use the _lock mutex to prevent simultanious calling of this function.

Definition at line 97 of file worker.cpp.

References _workers.

Member Data Documentation

Workers::shared_pointer Workers::_instance
staticprivate

the instance of this class

Definition at line 179 of file worker.h.

Referenced by instance(), and reference().

QMutex Workers::_mutex
staticprivate

mutex to protect the creation of the signelton

Definition at line 182 of file worker.h.

Referenced by instance(), and reference().

RingBuffer<CASSEvent>& cass::Workers::_rb
private

the ringbuffer

Definition at line 185 of file worker.h.

std::vector<Worker::shared_pointer> cass::Workers::_workers
private

container of workers

Definition at line 176 of file worker.h.

Referenced by end(), pause(), resume(), rethrowException(), running(), start(), and Workers().

QMutex cass::Workers::lock

a lock to be used by functions that are using this worker

Definition at line 159 of file worker.h.

Referenced by instance(), and reference().


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