aboutsummaryrefslogtreecommitdiff
path: root/src/stable/thread.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2012-11-05 22:41:51 +0000
committerMike Buland <eichlan@xagasoft.com>2012-11-05 22:41:51 +0000
commitec05778d5718a7912e506764d443a78d6a6179e3 (patch)
tree78a9a01532180030c095acefc45763f07c14edb8 /src/stable/thread.cpp
parentb20414ac1fe80a71a90601f4cd1767fa7014a9ba (diff)
downloadlibbu++-ec05778d5718a7912e506764d443a78d6a6179e3.tar.gz
libbu++-ec05778d5718a7912e506764d443a78d6a6179e3.tar.bz2
libbu++-ec05778d5718a7912e506764d443a78d6a6179e3.tar.xz
libbu++-ec05778d5718a7912e506764d443a78d6a6179e3.zip
Converted tabs to spaces with tabconv.
Diffstat (limited to '')
-rw-r--r--src/stable/thread.cpp36
1 files changed, 18 insertions, 18 deletions
diff --git a/src/stable/thread.cpp b/src/stable/thread.cpp
index 30443e6..ddb7ff5 100644
--- a/src/stable/thread.cpp
+++ b/src/stable/thread.cpp
@@ -10,7 +10,7 @@
10namespace Bu { subExceptionDef( ThreadException ); } 10namespace Bu { subExceptionDef( ThreadException ); }
11 11
12Bu::ThreadId::ThreadId( pthread_t tId ) : 12Bu::ThreadId::ThreadId( pthread_t tId ) :
13 tId( tId ) 13 tId( tId )
14{ 14{
15} 15}
16 16
@@ -20,12 +20,12 @@ Bu::ThreadId::ThreadId()
20 20
21bool Bu::ThreadId::operator==( const Bu::ThreadId &rhs ) 21bool Bu::ThreadId::operator==( const Bu::ThreadId &rhs )
22{ 22{
23 return pthread_equal( tId, rhs.tId ); 23 return pthread_equal( tId, rhs.tId );
24} 24}
25 25
26bool Bu::ThreadId::operator!=( const ThreadId &rhs ) 26bool Bu::ThreadId::operator!=( const ThreadId &rhs )
27{ 27{
28 return !pthread_equal( tId, rhs.tId ); 28 return !pthread_equal( tId, rhs.tId );
29} 29}
30 30
31Bu::Thread::Thread() 31Bu::Thread::Thread()
@@ -38,45 +38,45 @@ Bu::Thread::~Thread()
38 38
39Bu::ThreadId Bu::Thread::currentThread() 39Bu::ThreadId Bu::Thread::currentThread()
40{ 40{
41 return ThreadId( pthread_self() ); 41 return ThreadId( pthread_self() );
42} 42}
43 43
44bool Bu::Thread::start() 44bool Bu::Thread::start()
45{ 45{
46 if( pthread_create( &ptHandle, NULL, threadRunner, this ) ) 46 if( pthread_create( &ptHandle, NULL, threadRunner, this ) )
47 { 47 {
48 throw Bu::ThreadException("Could not start thread."); 48 throw Bu::ThreadException("Could not start thread.");
49 } 49 }
50 50
51 return true; 51 return true;
52} 52}
53 53
54bool Bu::Thread::stop() 54bool Bu::Thread::stop()
55{ 55{
56 pthread_cancel( ptHandle ); 56 pthread_cancel( ptHandle );
57 57
58 return true; 58 return true;
59} 59}
60 60
61void *Bu::Thread::threadRunner( void *pThread ) 61void *Bu::Thread::threadRunner( void *pThread )
62{ 62{
63 ((Thread *)pThread)->run(); 63 ((Thread *)pThread)->run();
64 pthread_exit( NULL ); 64 pthread_exit( NULL );
65 return NULL; 65 return NULL;
66} 66}
67 67
68bool Bu::Thread::join() 68bool Bu::Thread::join()
69{ 69{
70 pthread_join( ptHandle, NULL ); 70 pthread_join( ptHandle, NULL );
71 return true; 71 return true;
72} 72}
73 73
74void Bu::Thread::yield() 74void Bu::Thread::yield()
75{ 75{
76#ifndef WIN32 76#ifndef WIN32
77 pthread_yield(); 77 pthread_yield();
78#else 78#else
79 sched_yield(); 79 sched_yield();
80#endif 80#endif
81} 81}
82 82