diff options
author | Matthias Schiffer <matthias@gamezock.de> | 2009-04-29 19:13:39 +0200 |
---|---|---|
committer | Matthias Schiffer <matthias@gamezock.de> | 2009-04-29 19:13:39 +0200 |
commit | 5a61159a11e1db775a2b5dfebc46c12ff2616b5a (patch) | |
tree | 8fb518d5f60b4ff0d2ff363ed9936a70d216f941 /src/Common/ThreadManager.h | |
parent | 539d7e2cfbc8fef2837c47312107a8314108158b (diff) | |
download | mad-5a61159a11e1db775a2b5dfebc46c12ff2616b5a.tar mad-5a61159a11e1db775a2b5dfebc46c12ff2616b5a.zip |
Worker-Thread kann jetzt in den Hintergrund gestellt werden
Diffstat (limited to 'src/Common/ThreadManager.h')
-rw-r--r-- | src/Common/ThreadManager.h | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/Common/ThreadManager.h b/src/Common/ThreadManager.h index 07ab196..6e8616f 100644 --- a/src/Common/ThreadManager.h +++ b/src/Common/ThreadManager.h @@ -41,6 +41,8 @@ class ThreadManager : public Initializable { gl_thread_t mainThread, workerThread, loggerThread; std::set<gl_thread_t> threads; + gl_lock_t threadLock; + gl_lock_t runLock; bool running; @@ -64,19 +66,32 @@ class ThreadManager : public Initializable { void workerFunc(); + void threadFinished(gl_thread_t thread) { + gl_lock_lock(threadLock); + threads.erase(thread); + gl_lock_unlock(threadLock); + + gl_thread_join(thread, 0); + } + protected: virtual void doInit(); virtual void doDeinit(); public: - bool isThisMainThread() const { + bool isThisMainThread() { return (mainThread == (gl_thread_t)gl_thread_self()); } - bool isThisWorkerThread() const { - return (workerThread == (gl_thread_t)gl_thread_self()); + bool isThisWorkerThread() { + gl_lock_lock(threadLock); + bool ret = (workerThread == (gl_thread_t)gl_thread_self()); + gl_lock_unlock(threadLock); + return ret; } + void detach(); + void pushWork(const sigc::slot<void> &newWork); static ThreadManager* get() { |