From 9bdb93b01b037358a209af040b561fca3a51851b Mon Sep 17 00:00:00 2001 From: Pixel Date: Fri, 6 Apr 2012 10:38:13 -0700 Subject: A few improvements over how a threaded TaskMan works. Now its own exported class. Also has a proper exception handling in its caller. --- includes/TaskMan.h | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'includes') 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 static T * createTask(T * t, Task * stick = NULL) { TaskMan::registerTask(t, stick); return t; } -- cgit v1.2.3