History

switch from pthread mutex to QMutex

Brad Hefta-Gaub committed 12 years ago

Commit 9bc4a3d1 parent 2c30b8b12 files · +111 −131Browse files

Showing the changes to libraries/shared/src/GenericThread.cpp (1 of 12 files). Show all

Unified · Split

libraries/shared/src/GenericThread.cpp+7−9
@@ -14,12 +14,10 @@ GenericThread::GenericThread() : · 13 unmodified lines
1414 _stopThread(false),
1515 _isThreaded(false) // assume non-threaded, must call initialize()
1616 {
17− pthread_mutex_init(&_mutex, 0);
1817 }
1918
2019 GenericThread::~GenericThread() {
2120 terminate();
22− pthread_mutex_destroy(&_mutex);
2321 }
2422
2523 void GenericThread::initialize(bool isThreaded) {
@@ -32,30 +30,30 @@ void GenericThread::initialize(bool isThreaded) { · 6 unmodified lines
3230 void GenericThread::terminate() {
3331 if (_isThreaded) {
3432 _stopThread = true;
35− pthread_join(_thread, NULL);
33+ pthread_join(_thread, NULL);
3634 _isThreaded = false;
3735 }
3836 }
3937
4038 void* GenericThread::threadRoutine() {
4139 while (!_stopThread) {
42−
40+
4341 // override this function to do whatever your class actually does, return false to exit thread early
4442 if (!process()) {
4543 break;
4644 }
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
4947 // callers responsibility to continuously call this method
5048 if (!_isThreaded) {
5149 break;
5250 }
5351 }
54−
52+
5553 if (_isThreaded) {
56− pthread_exit(0);
54+ pthread_exit(0);
5755 }
58− return NULL;
56+ return NULL;
5957 }
6058
6159 extern "C" void* GenericThreadEntry(void* arg) {