From cfee7a5f9a7d0c58db657c344a54603bacb0693d Mon Sep 17 00:00:00 2001 From: Micke Prag Date: Mon, 11 Oct 2010 10:29:37 +0000 Subject: [PATCH] Removed the thread event system. This is obsolete by our new standalone event system --- telldus-core/common/Thread.cpp | 73 ---------------------------------- telldus-core/common/Thread.h | 3 -- 2 files changed, 76 deletions(-) diff --git a/telldus-core/common/Thread.cpp b/telldus-core/common/Thread.cpp index 7f90215b..a13cd1d4 100644 --- a/telldus-core/common/Thread.cpp +++ b/telldus-core/common/Thread.cpp @@ -24,41 +24,14 @@ public: pthread_t thread; pthread_cond_t noEvent, noWait; #endif - MUTEX_T mutex; - - //Must be locked by the mutex! - bool hasEvent; - std::string strMessage; - int intMessage; }; Thread::Thread() { d = new ThreadPrivate; d->thread = 0; - initMutex(&d->mutex); - - lockMutex(&d->mutex); - d->hasEvent = false; - unlockMutex(&d->mutex); - -#ifdef _WINDOWS - d->noEvent = CreateEvent(0, FALSE, FALSE, 0); - d->noWait = CreateEvent(0, FALSE, FALSE, 0); -#else - pthread_cond_init(&d->noEvent, NULL); - pthread_cond_init(&d->noWait, NULL); -#endif } Thread::~Thread() { - destroyMutex(&d->mutex); -#ifdef _WINDOWS - CloseHandle(d->noEvent); - CloseHandle(d->noWait); -#else - pthread_cond_destroy(&d->noEvent); - pthread_cond_destroy(&d->noWait); -#endif delete d; } @@ -91,52 +64,6 @@ void *Thread::exec( void *ptr ) { return 0; } -std::string Thread::waitForEvent(int *intMessage) { - std::string strMessage; - lockMutex(&d->mutex); - while(!d->hasEvent) { -#ifdef _WINDOWS - unlockMutex(&d->mutex); - WaitForSingleObject(d->noWait, INFINITE); - lockMutex(&d->mutex); -#else - pthread_cond_wait(&d->noWait, &d->mutex); -#endif - } - d->hasEvent = false; - strMessage = d->strMessage; - (*intMessage) = d->intMessage; - unlockMutex(&d->mutex); -#ifdef _WINDOWS - SetEvent(d->noEvent); -#else - pthread_cond_broadcast(&d->noEvent); -#endif - return strMessage; -} - -void Thread::sendEvent(const std::string &strMessage, int intMessage) { - lockMutex(&d->mutex); - while (d->hasEvent) { //We have an unprocessed event -#ifdef _WINDOWS - unlockMutex(&d->mutex); - WaitForSingleObject(d->noEvent, INFINITE); - lockMutex(&d->mutex); -#else - pthread_cond_wait(&d->noEvent, &d->mutex); -#endif - } - d->hasEvent = true; - d->strMessage = strMessage; - d->intMessage = intMessage; - unlockMutex(&d->mutex); -#ifdef _WINDOWS - SetEvent(d->noWait); -#else - pthread_cond_broadcast(&d->noWait); -#endif -} - void Thread::initMutex(MUTEX_T * m) { #ifdef _WINDOWS InitializeCriticalSection(m); diff --git a/telldus-core/common/Thread.h b/telldus-core/common/Thread.h index 7f30052f..35fbe1f3 100644 --- a/telldus-core/common/Thread.h +++ b/telldus-core/common/Thread.h @@ -31,8 +31,6 @@ namespace TelldusCore { void start(); bool wait(); - void sendEvent(const std::string &string, int integer = 0); - static void initMutex(MUTEX_T *m); static void destroyMutex(MUTEX_T *m); static void lockMutex(MUTEX_T *m); @@ -40,7 +38,6 @@ namespace TelldusCore { protected: virtual void run() = 0; - std::string waitForEvent(int *intMessage); private: static void* exec( void *ptr );