#include <mmsthread.h>
Public Member Functions | |
MMSThread (string identity="MMSThread", int priority=0, bool autodetach=true) | |
Constructor. | |
virtual | ~MMSThread () |
Destructor. | |
virtual void | threadMain ()=0 |
Virtual main method for the thread. | |
virtual bool | start () |
Create and start a new thread. | |
virtual bool | isRunning () |
Check if the thread is running. | |
void | detach () |
Mark the thread as detached. | |
bool | cancel () |
Cancel execution of a thread. | |
void | join () |
The caller of this method will wait of the termination of the thread. | |
void | setStacksize (size_t stacksize=1000000) |
Set the size of the stack for the new thread. | |
Public Attributes | |
string | identity |
identification string | |
Private Member Functions | |
void | run () |
the code of this method runs in the new thread and calls the virtual threadMain() | |
Static Private Member Functions | |
static void * | runThread (void *thiz) |
static helper routine to call this->run() | |
Private Attributes | |
MMSMutex | startlock |
helper mutex to perform a safe start | |
bool | starting |
starting thread is in progress | |
bool | running |
thread is running | |
bool | detached |
if thread is detached, its resources are automatically released when it terminates | |
pthread_attr_t | tattr |
thread attributes | |
sched_param | param |
scheduling parameter | |
pthread_t | id |
id of the thread, valid for the running state | |
int | priority |
requested priority of the thread | |
bool | autodetach |
should thread automatically detached? | |
size_t | stacksize |
requested stack size |
This class includes the base functionality available for all threads within MMS/DISKO. This class cannot be constructed. Only classes which are derived from this class can be constructed.
Definition at line 47 of file mmsthread.h.
MMSThread::MMSThread | ( | string | identity = "MMSThread" , |
|
int | priority = 0 , |
|||
bool | autodetach = true | |||
) |
Constructor.
identity | identification string | |
priority | requested priority of the thread, default is 0 | |
autodetach | automatically detach the thread after starting, default is true |
Definition at line 59 of file mmsthread.cpp.
MMSThread::~MMSThread | ( | ) | [virtual] |
void * MMSThread::runThread | ( | void * | thiz | ) | [static, private] |
void MMSThread::run | ( | ) | [private] |
the code of this method runs in the new thread and calls the virtual threadMain()
Definition at line 89 of file mmsthread.cpp.
virtual void MMSThread::threadMain | ( | ) | [pure virtual] |
Virtual main method for the thread.
This virtual method is empty and have to be setup with code by a derived class. The MMSThread class is only the base class and cannot be constructed.
Implemented in MMSEventThread, MMSImportScheduler, MMSSwitcherThread, MMSFlashThread, MMSFBWindowManagerThread, MMSGIFLoader, MMSImageWidgetThread, MMSInputWidgetThread, MMSLabelWidgetThread, MMSWindowAction, MMSInputLISThread, MMSInputThread, MMSProcessMonitor, MMSPulser, MMSTCPServer, MMSTCPServerThread, MMSThreadServer, and MMSTimer.
bool MMSThread::start | ( | void | ) | [virtual] |
Create and start a new thread.
If the method returns true, it is possible, that the new thread is already finished.
Reimplemented in MMSFlashThread, and MMSThreadServer.
Definition at line 115 of file mmsthread.cpp.
bool MMSThread::isRunning | ( | ) | [virtual] |
Check if the thread is running.
Reimplemented in MMSPulser.
Definition at line 160 of file mmsthread.cpp.
void MMSThread::detach | ( | ) |
Mark the thread as detached.
Definition at line 167 of file mmsthread.cpp.
bool MMSThread::cancel | ( | ) |
Cancel execution of a thread.
Definition at line 173 of file mmsthread.cpp.
void MMSThread::join | ( | ) |
The caller of this method will wait of the termination of the thread.
Definition at line 202 of file mmsthread.cpp.
void MMSThread::setStacksize | ( | size_t | stacksize = 1000000 |
) |
Set the size of the stack for the new thread.
The stack size determines the minimum size (in bytes) that will be allocated.
stacksize | size of the stack in bytes |
The stack size must be changed before the start() method will be called.
Definition at line 208 of file mmsthread.cpp.
MMSMutex MMSThread::startlock [private] |
helper mutex to perform a safe start
Reimplemented in MMSPulser.
Definition at line 51 of file mmsthread.h.
bool MMSThread::starting [private] |
bool MMSThread::running [private] |
bool MMSThread::detached [private] |
if thread is detached, its resources are automatically released when it terminates
Definition at line 60 of file mmsthread.h.
pthread_attr_t MMSThread::tattr [private] |
sched_param MMSThread::param [private] |
pthread_t MMSThread::id [private] |
id of the thread, valid for the running state
Reimplemented in MMSWindowAction.
Definition at line 70 of file mmsthread.h.
int MMSThread::priority [private] |
bool MMSThread::autodetach [private] |
size_t MMSThread::stacksize [private] |
string MMSThread::identity |