diff options
author | Pixel <pixel@nobis-crew.org> | 2011-12-04 11:53:55 -0800 |
---|---|---|
committer | Pixel <pixel@nobis-crew.org> | 2011-12-04 11:53:55 -0800 |
commit | 67432fe6501e1ae011870310b1dbcfb49b5233a8 (patch) | |
tree | fded68e0b61d4fcdfd2f424f53a5c3b8370d477c /includes | |
parent | f99192cb59bb3e09ae4841bb790c57969fbe2003 (diff) |
Refactored the Thread code a bit, and created the GlobalThread class, for threads that are created on startup.
Diffstat (limited to 'includes')
-rw-r--r-- | includes/Threads.h | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/includes/Threads.h b/includes/Threads.h index bc2670d..f6aed5a 100644 --- a/includes/Threads.h +++ b/includes/Threads.h @@ -22,23 +22,30 @@ class Lock { class ThreadHelper; -class Thread : public AtExit { +class Thread { public: virtual ~Thread(); void threadStart(); void * join(); protected: - Thread(bool registerAtExit = false) : AtExit(registerAtExit ? 1 : -1), m_joined(false) { } + Thread() : m_joined(false) { } virtual void * proc() = 0; - virtual void threadExit(); + virtual void threadExit() { }; private: pthread_t m_thread; volatile bool m_joined; - virtual void doExit() { join(); } friend class ThreadHelper; }; +class GlobalThread : public Thread, public AtStart, public AtExit { + protected: + GlobalThread(int startOrder = 10) : AtStart(startOrder), AtExit(1) { } + private: + virtual void doStart() { threadStart(); } + virtual void doExit() { join(); } +}; + template<class T> class Queue { public: |