From 67432fe6501e1ae011870310b1dbcfb49b5233a8 Mon Sep 17 00:00:00 2001 From: Pixel Date: Sun, 4 Dec 2011 11:53:55 -0800 Subject: Refactored the Thread code a bit, and created the GlobalThread class, for threads that are created on startup. --- includes/Threads.h | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'includes') 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 Queue { public: -- cgit v1.2.3