diff --git a/base/condition.hpp b/base/condition.hpp index 2764d475a5..6dc2c7f431 100644 --- a/base/condition.hpp +++ b/base/condition.hpp @@ -13,19 +13,6 @@ namespace threads { -#if !defined(OMIM_OS_WINDOWS_NATIVE) && !defined(OMIM_OS_BADA) - // only for pthreads - struct CondDeleter - { - void operator()(pthread_cond_t * var) - { - ::pthread_cond_destroy(var); - delete var; - } - }; - -#endif - /// Implements mutexed condition semantics class Condition { @@ -36,7 +23,7 @@ namespace threads #if defined(OMIM_OS_WINDOWS_NATIVE) CONDITION_VARIABLE m_Condition; #else - shared_ptr m_Condition; + pthread_cond_t m_Condition; #endif #endif @@ -48,8 +35,15 @@ namespace threads #elif defined(OMIM_OS_WINDOWS_NATIVE) ::InitializeConditionVariable(&m_Condition); #else - m_Condition = shared_ptr(new pthread_cond_t(), CondDeleter()); - ::pthread_cond_init(m_Condition.get(), 0); + ::pthread_cond_init(&m_Condition, 0); +#endif + } + + ~Condition() + { +#if !defined(OMIM_OS_WINDOWS_NATIVE) && !defined(OMIM_OS_BADA) + // only for pthreads + ::pthread_cond_destroy(&m_Condition); #endif } @@ -60,7 +54,7 @@ namespace threads #elif defined(OMIM_OS_WINDOWS_NATIVE) ::WakeConditionVariable(&m_Condition); #else - ::pthread_cond_signal(m_Condition.get()); + ::pthread_cond_signal(&m_Condition); #endif } @@ -71,7 +65,7 @@ namespace threads #elif defined(OMIM_OS_WINDOWS_NATIVE) ::SleepConditionVariableCS(&m_Condition, &m_Mutex.m_Mutex, INFINITE); #else - ::pthread_cond_wait(m_Condition.get(), &m_Mutex.m_Mutex); + ::pthread_cond_wait(&m_Condition, &m_Mutex.m_Mutex); #endif } diff --git a/base/mutex.hpp b/base/mutex.hpp index 3da861ba87..4b5bef2080 100644 --- a/base/mutex.hpp +++ b/base/mutex.hpp @@ -10,9 +10,6 @@ #include #endif -#include "../std/shared_ptr.hpp" - - namespace threads { /// Mutex primitive, used only for synchronizing this process threads @@ -54,6 +51,8 @@ namespace threads { #if defined(OMIM_OS_WINDOWS_NATIVE) ::DeleteCriticalSection(&m_Mutex); +#elif !defined(OMIM_OS_BADA) + ::pthread_mutex_destroy(&m_Mutex); #endif } @@ -63,9 +62,9 @@ namespace threads m_Mutex.Acquire(); #elif defined(OMIM_OS_WINDOWS_NATIVE) ::EnterCriticalSection(&m_Mutex); - #else +#else ::pthread_mutex_lock(&m_Mutex); - #endif +#endif } void Unlock() @@ -74,9 +73,9 @@ namespace threads m_Mutex.Release(); #elif defined(OMIM_OS_WINDOWS_NATIVE) ::LeaveCriticalSection(&m_Mutex); - #else +#else ::pthread_mutex_unlock(&m_Mutex); - #endif +#endif } };