From d440c3f50a918a932293ad98bcec96eaa4683222 Mon Sep 17 00:00:00 2001 From: Pixel Date: Sun, 4 Dec 2011 01:19:09 -0800 Subject: Reworked some things in the architecture, mainly exceptions and asserts. -) Removed Assert() -) Added AAssert(), IAssert(), RAssert(), TAssert() and Failure() -) Reworked all asserts in the code, and added meaningful messages to them. -) Changed the way the startup code is generated; BALAU_STARTUP is no longer necessary. --- includes/Threads.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'includes/Threads.h') diff --git a/includes/Threads.h b/includes/Threads.h index ca60627..bc2670d 100644 --- a/includes/Threads.h +++ b/includes/Threads.h @@ -1,5 +1,6 @@ #pragma once +#include #include namespace Balau { @@ -21,17 +22,19 @@ class Lock { class ThreadHelper; -class Thread { +class Thread : public AtExit { public: virtual ~Thread(); void threadStart(); void * join(); protected: - Thread() : m_joined(false) { } + Thread(bool registerAtExit = false) : AtExit(registerAtExit ? 1 : -1), m_joined(false) { } virtual void * proc() = 0; + virtual void threadExit(); private: pthread_t m_thread; - bool m_joined; + volatile bool m_joined; + virtual void doExit() { join(); } friend class ThreadHelper; }; -- cgit v1.2.3