![]() |
GemaCoreLib
The GeMA Core library
|
Our thread wrapper, specialized for running tasks from the thread manager queue. More...
#include <gmThreadManager.h>
Public Member Functions | |
GmThread (GmThreadManager *manager, int tid) | |
Thread wrapper constructor for a worker thread. Creates the equivalent QThread object without starting it. More... | |
GmThread (GmThreadManager *manager) | |
Thread wrapper constructor for the main thread. Should be created FROM the main thread. | |
~GmThread () | |
Destructor. If the wrapper is not over the main thread, destroys it. Expects that the caller has already made sure that the wrapped thread is no longer running. | |
int | id () const |
Returns the thread id (a value between 1 and the maximum number of threads) | |
GmThreadManager * | threadManager () const |
Returns a pointer to the thread manager. | |
QThread * | thread () const |
Returns the pointer to the associated Qt thread. | |
bool | cancelPending () const |
Do we have a pending request to cancel this thread work or any other thread has aborted? | |
LuaEnv * | luaEnv () const |
Returns the Lua environment associated with this thread. | |
Private Member Functions | |
void | start () |
Wrapper over QThread::start(). Should NOT be called over the main thead. | |
bool | wait (unsigned long time=ULONG_MAX) |
Wrapper over QThread::wait(). Should NOT be called over the main thead. | |
void | run () |
Thread execution routine. | |
Private Attributes | |
int | _tid |
Our thread id. | |
QThread * | _thread |
The thread. | |
GmThreadManager * | _tm |
The thread manager. | |
QWaitCondition | _idleCond |
The condition variable used to wake up a thread waiting for jobs. | |
Friends | |
class | GmThreadManager |
class | GmInternalThread |
Our thread wrapper, specialized for running tasks from the thread manager queue.
This class does not inherits directly from QThread in order to allow for wrapping the main application thread inside a GmThread. This in turn allows us to handle the single thread execution case, without threads, in an uniform way.
GmThread::GmThread | ( | GmThreadManager * | manager, |
int | tid | ||
) |
Thread wrapper constructor for a worker thread. Creates the equivalent QThread object without starting it.
The given thread id must be unique and between 1 and the maximum number of threads.