diff options
author | Pixel <pixel@nobis-crew.org> | 2012-04-06 10:38:13 -0700 |
---|---|---|
committer | Pixel <pixel@nobis-crew.org> | 2012-04-06 10:38:13 -0700 |
commit | 9bdb93b01b037358a209af040b561fca3a51851b (patch) | |
tree | 75772799ae8b14f5cdc9bb323ab88c327affc745 /includes | |
parent | c385d3ea8c6f96bbcf7d64f0a1890ab2ef5096ee (diff) |
A few improvements over how a threaded TaskMan works. Now its own exported class. Also has a proper exception handling in its caller.
Diffstat (limited to 'includes')
-rw-r--r-- | includes/TaskMan.h | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/includes/TaskMan.h b/includes/TaskMan.h index 088d5d7..6c446b7 100644 --- a/includes/TaskMan.h +++ b/includes/TaskMan.h @@ -25,6 +25,15 @@ class Async; class TaskMan { public: + class TaskManThread : public Thread { + public: + virtual ~TaskManThread(); + virtual void * proc(); + void stopMe(int code = 0) { m_taskMan->stopMe(code); } + private: + TaskMan * m_taskMan; + }; + TaskMan(); ~TaskMan(); int mainLoop(); @@ -32,8 +41,12 @@ class TaskMan { struct ev_loop * getLoop() { return m_loop; } void signalTask(Task * t); static void stop(int code); - void stopMe(int code) { m_stopped = true; m_stopCode = code; } - static Thread * createThreadedTaskMan(); + void stopMe(int code = 0); + static TaskManThread * createThreadedTaskMan() { + TaskManThread * r = new TaskManThread(); + r->threadStart(); + return r; + } bool stopped() { return m_stopped; } template<class T> static T * createTask(T * t, Task * stick = NULL) { TaskMan::registerTask(t, stick); return t; } |