CFEL - ASG Software Suite
2.5.0
CASS
|
Worker Thread Handler. More...
#include <worker.h>
Public Types | |
typedef std::tr1::shared_ptr< Workers > | shared_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... | |
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
typedef std::tr1::shared_ptr<Workers> cass::Workers::shared_pointer |
|
private |
constructor.
will create the requested amount of threads. and calls the load settings member of one of them.
rb | the rinbguffer we get the events from |
ratemeter | the ratemeter object to measure the rate |
parent | the qt parent of this object |
Definition at line 87 of file worker.cpp.
References _workers.
Referenced by instance().
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().
|
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.
rb | the rinbguffer we get the events from |
ratemeter | the ratemeter object to measure the rate |
parent | the qt parent of this object |
Definition at line 66 of file worker.cpp.
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.
|
static |
return a reference to the instance itselve if it exists
Definition at line 76 of file worker.cpp.
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
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.
|
staticprivate |
the instance of this class
Definition at line 179 of file worker.h.
Referenced by instance(), and reference().
|
staticprivate |
mutex to protect the creation of the signelton
Definition at line 182 of file worker.h.
Referenced by instance(), and reference().
|
private |
|
private |
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().