Changeset ceec23
- Timestamp:
- 02/03/12 15:50:04 (3 months ago)
- Branches:
- ('master', 'deebf2045e7119c339412580f37a1e653f7d5715')('controller-upgrade', '00f95d22e12d96ef089e0902ef62ae8ce841dc6f')
- Children:
- 868c8b322c052181e36262773192fb03fa02fdea
- Parents:
- 938187b2a652cc6691f5a3b2ec9d0d73fd4e6748
- git-author:
- Micke Prag <micke.prag@telldus.se>2012-02-03 15:50:04+01:00
- git-committer:
- Micke Prag <micke.prag@telldus.se>2012-02-03 15:50:04+01:00
- Location:
- telldus-core/common
- Files:
-
- 2 edited
-
Thread.cpp (modified) (5 diffs)
-
Thread.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
telldus-core/common/Thread.cpp
r23be1d rceec23 15 15 #include <windows.h> 16 16 #endif 17 #include "EventHandler.h" 17 18 18 19 using namespace TelldusCore; … … 21 22 public: 22 23 bool running; 24 EventRef threadStarted; 25 Mutex *mutex; 23 26 #ifdef _WINDOWS 24 27 HANDLE thread; … … 32 35 d = new ThreadPrivate; 33 36 d->thread = 0; 37 d->mutex = 0; 34 38 } 35 39 … … 45 49 pthread_create(&d->thread, NULL, &Thread::exec, this ); 46 50 #endif 51 } 52 53 void Thread::startAndLock(Mutex *lock) { 54 EventHandler handler; 55 d->threadStarted = handler.addEvent(); 56 d->mutex = lock; 57 this->start(); 58 handler.waitForAny(); 59 d->threadStarted.reset(); 47 60 } 48 61 … … 65 78 Thread *t = reinterpret_cast<Thread *>(ptr); 66 79 if (t) { 80 if (t->d->threadStarted) { 81 t->d->mutex->lock(); 82 t->d->threadStarted->signal(); 83 } 67 84 t->run(); 85 if (t->d->mutex) { 86 t->d->mutex->unlock(); 87 } 68 88 t->d->running = false; 69 89 } -
telldus-core/common/Thread.h
r8105da rceec23 14 14 15 15 #include <string> 16 #include "Mutex.h" 16 17 17 18 namespace TelldusCore { … … 22 23 virtual ~Thread(); 23 24 void start(); 25 void startAndLock(Mutex *); 24 26 bool wait(); 25 27
Note: See TracChangeset
for help on using the changeset viewer.
