summaryrefslogtreecommitdiff
path: root/includes/Threads.h
diff options
context:
space:
mode:
authorPixel <pixel@nobis-crew.org>2011-12-04 01:19:09 -0800
committerPixel <pixel@nobis-crew.org>2011-12-04 01:20:10 -0800
commitd440c3f50a918a932293ad98bcec96eaa4683222 (patch)
tree33e8e42a8e4506ae9da70cdb44dd133bde7f7219 /includes/Threads.h
parente5577eb7a643ce7885e5d14660a6d24254161622 (diff)
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.
Diffstat (limited to 'includes/Threads.h')
-rw-r--r--includes/Threads.h9
1 files changed, 6 insertions, 3 deletions
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 <AtStartExit.h>
#include <pthread.h>
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;
};