aboutsummaryrefslogtreecommitdiff
path: root/src/stable/thread.h
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2012-04-06 18:57:05 +0000
committerMike Buland <eichlan@xagasoft.com>2012-04-06 18:57:05 +0000
commit9a602d38035972e6aabfb3bb4da2b1ee53f9f7be (patch)
treedc4485da7853538cc251610f26ffd6a700b30143 /src/stable/thread.h
parentb7745f00eacb2ca5b9c56331006f4f37d2566fdc (diff)
downloadlibbu++-9a602d38035972e6aabfb3bb4da2b1ee53f9f7be.tar.gz
libbu++-9a602d38035972e6aabfb3bb4da2b1ee53f9f7be.tar.bz2
libbu++-9a602d38035972e6aabfb3bb4da2b1ee53f9f7be.tar.xz
libbu++-9a602d38035972e6aabfb3bb4da2b1ee53f9f7be.zip
Threads can tell you their own ids now, and they can also report that they
failed to start.
Diffstat (limited to 'src/stable/thread.h')
-rw-r--r--src/stable/thread.h9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/stable/thread.h b/src/stable/thread.h
index f4b961f..0a0d8bb 100644
--- a/src/stable/thread.h
+++ b/src/stable/thread.h
@@ -10,8 +10,11 @@
10 10
11#include <pthread.h> 11#include <pthread.h>
12 12
13#include "bu/exceptionbase.h"
14
13namespace Bu 15namespace Bu
14{ 16{
17 subExceptionDecl( ThreadException );
15 class ThreadId 18 class ThreadId
16 { 19 {
17 friend class Thread; 20 friend class Thread;
@@ -49,6 +52,7 @@ namespace Bu
49 virtual ~Thread(); 52 virtual ~Thread();
50 53
51 static ThreadId currentThread(); 54 static ThreadId currentThread();
55 ThreadId getId() { return ThreadId( ptHandle ); }
52 56
53 /** 57 /**
54 * Begin thread execution. This will call the overridden run function, 58 * Begin thread execution. This will call the overridden run function,
@@ -93,12 +97,11 @@ namespace Bu
93 97
94 private: 98 private:
95 pthread_t ptHandle; /**< Internal handle to the posix thread. */ 99 pthread_t ptHandle; /**< Internal handle to the posix thread. */
96 int nHandle; /**< Numeric handle to the posix thread. */
97 100
98 protected: 101 protected:
99 /** 102 /**
100 * The workhorse of the Thread class. This is the function that will run 103 * The workhorse of the Thread class. This is the function that will
101 * in the thread, when this function exits the thread dies and is 104 * run in the thread, when this function exits the thread dies and is
102 * cleaned up by the system. Make sure to read up on ThreadMutex, 105 * cleaned up by the system. Make sure to read up on ThreadMutex,
103 * ThreadCondition, and cancel to see how to control and protect 106 * ThreadCondition, and cancel to see how to control and protect
104 * everything you do in a safe way within this function. 107 * everything you do in a safe way within this function.