Showing the changes to libraries/shared/src/GenericThread.cpp (1 of 12 files). Show all
Unified · Split
| @@ -14,12 +14,10 @@ GenericThread::GenericThread() : · 13 unmodified lines | ||
| 14 | 14 | _stopThread(false), |
| 15 | 15 | _isThreaded(false) // assume non-threaded, must call initialize() |
| 16 | 16 | { |
| 17 | − pthread_mutex_init(&_mutex, 0); | |
| 18 | 17 | } |
| 19 | 18 | |
| 20 | 19 | GenericThread::~GenericThread() { |
| 21 | 20 | terminate(); |
| 22 | − pthread_mutex_destroy(&_mutex); | |
| 23 | 21 | } |
| 24 | 22 | |
| 25 | 23 | void GenericThread::initialize(bool isThreaded) { |
| @@ -32,30 +30,30 @@ void GenericThread::initialize(bool isThreaded) { · 6 unmodified lines | ||
| 32 | 30 | void GenericThread::terminate() { |
| 33 | 31 | if (_isThreaded) { |
| 34 | 32 | _stopThread = true; |
| 35 | − pthread_join(_thread, NULL); | |
| 33 | + pthread_join(_thread, NULL); | |
| 36 | 34 | _isThreaded = false; |
| 37 | 35 | } |
| 38 | 36 | } |
| 39 | 37 | |
| 40 | 38 | void* GenericThread::threadRoutine() { |
| 41 | 39 | while (!_stopThread) { |
| 42 | − | |
| 40 | + | |
| 43 | 41 | // override this function to do whatever your class actually does, return false to exit thread early |
| 44 | 42 | if (!process()) { |
| 45 | 43 | break; |
| 46 | 44 | } |
| 47 | − | |
| 48 | − // In non-threaded mode, this will break each time you call it so it's the | |
| 45 | + | |
| 46 | + // In non-threaded mode, this will break each time you call it so it's the | |
| 49 | 47 | // callers responsibility to continuously call this method |
| 50 | 48 | if (!_isThreaded) { |
| 51 | 49 | break; |
| 52 | 50 | } |
| 53 | 51 | } |
| 54 | − | |
| 52 | + | |
| 55 | 53 | if (_isThreaded) { |
| 56 | − pthread_exit(0); | |
| 54 | + pthread_exit(0); | |
| 57 | 55 | } |
| 58 | − return NULL; | |
| 56 | + return NULL; | |
| 59 | 57 | } |
| 60 | 58 | |
| 61 | 59 | extern "C" void* GenericThreadEntry(void* arg) { |