aboutsummaryrefslogtreecommitdiff
path: root/src/stable/thread.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2012-04-06 18:45:08 +0000
committerMike Buland <eichlan@xagasoft.com>2012-04-06 18:45:08 +0000
commitb7745f00eacb2ca5b9c56331006f4f37d2566fdc (patch)
tree62530f6a0631d13e1289b19800612548dca8fb7b /src/stable/thread.cpp
parent9fa0f9cea3b92b3d44257a612731456fea629c68 (diff)
downloadlibbu++-b7745f00eacb2ca5b9c56331006f4f37d2566fdc.tar.gz
libbu++-b7745f00eacb2ca5b9c56331006f4f37d2566fdc.tar.bz2
libbu++-b7745f00eacb2ca5b9c56331006f4f37d2566fdc.tar.xz
libbu++-b7745f00eacb2ca5b9c56331006f4f37d2566fdc.zip
Supports ThreadIds now, you can also get the thread id of any thread, and
compare ThreadId objects.
Diffstat (limited to '')
-rw-r--r--src/stable/thread.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/stable/thread.cpp b/src/stable/thread.cpp
index e4563a2..0d0b768 100644
--- a/src/stable/thread.cpp
+++ b/src/stable/thread.cpp
@@ -9,6 +9,25 @@
9 9
10#include "bu/config.h" 10#include "bu/config.h"
11 11
12Bu::ThreadId::ThreadId( pthread_t tId ) :
13 tId( tId )
14{
15}
16
17Bu::ThreadId::ThreadId()
18{
19}
20
21bool Bu::ThreadId::operator==( const Bu::ThreadId &rhs )
22{
23 return pthread_equal( tId, rhs.tId );
24}
25
26bool Bu::ThreadId::operator!=( const ThreadId &rhs )
27{
28 return !pthread_equal( tId, rhs.tId );
29}
30
12Bu::Thread::Thread() 31Bu::Thread::Thread()
13{ 32{
14} 33}
@@ -17,6 +36,11 @@ Bu::Thread::~Thread()
17{ 36{
18} 37}
19 38
39Bu::ThreadId Bu::Thread::currentThread()
40{
41 return ThreadId( pthread_self() );
42}
43
20bool Bu::Thread::start() 44bool Bu::Thread::start()
21{ 45{
22 nHandle = pthread_create( &ptHandle, NULL, threadRunner, this ); 46 nHandle = pthread_create( &ptHandle, NULL, threadRunner, this );