diff options
| author | Mike Buland <eichlan@xagasoft.com> | 2012-11-05 22:41:51 +0000 |
|---|---|---|
| committer | Mike Buland <eichlan@xagasoft.com> | 2012-11-05 22:41:51 +0000 |
| commit | ec05778d5718a7912e506764d443a78d6a6179e3 (patch) | |
| tree | 78a9a01532180030c095acefc45763f07c14edb8 /src/stable/thread.cpp | |
| parent | b20414ac1fe80a71a90601f4cd1767fa7014a9ba (diff) | |
| download | libbu++-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.cpp | 36 |
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 @@ | |||
| 10 | namespace Bu { subExceptionDef( ThreadException ); } | 10 | namespace Bu { subExceptionDef( ThreadException ); } |
| 11 | 11 | ||
| 12 | Bu::ThreadId::ThreadId( pthread_t tId ) : | 12 | Bu::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 | ||
| 21 | bool Bu::ThreadId::operator==( const Bu::ThreadId &rhs ) | 21 | bool 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 | ||
| 26 | bool Bu::ThreadId::operator!=( const ThreadId &rhs ) | 26 | bool 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 | ||
| 31 | Bu::Thread::Thread() | 31 | Bu::Thread::Thread() |
| @@ -38,45 +38,45 @@ Bu::Thread::~Thread() | |||
| 38 | 38 | ||
| 39 | Bu::ThreadId Bu::Thread::currentThread() | 39 | Bu::ThreadId Bu::Thread::currentThread() |
| 40 | { | 40 | { |
| 41 | return ThreadId( pthread_self() ); | 41 | return ThreadId( pthread_self() ); |
| 42 | } | 42 | } |
| 43 | 43 | ||
| 44 | bool Bu::Thread::start() | 44 | bool 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 | ||
| 54 | bool Bu::Thread::stop() | 54 | bool 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 | ||
| 61 | void *Bu::Thread::threadRunner( void *pThread ) | 61 | void *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 | ||
| 68 | bool Bu::Thread::join() | 68 | bool 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 | ||
| 74 | void Bu::Thread::yield() | 74 | void 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 | ||
