X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Fcore%2Fsemaphore.cpp;fp=source%2Fcore%2Fsemaphore.cpp;h=bd1180b805b2701231e7833414717ea8bd7a9802;hp=bba39642c8c6aee8c52da11e931555a13645d485;hb=cfc8e0b7b15ea505bd6a6a9599cbc5ce1e316963;hpb=7db1e6d50594b47a32ecca5a349a4e8540f890c0 diff --git a/source/core/semaphore.cpp b/source/core/semaphore.cpp index bba3964..bd1180b 100644 --- a/source/core/semaphore.cpp +++ b/source/core/semaphore.cpp @@ -4,6 +4,7 @@ This file is part of libmspcore Copyright © 2006 Mikko Rasa, Mikkosoft Productions Distributed under the LGPL */ + #ifndef WIN32 #include #endif @@ -29,6 +30,27 @@ Semaphore::Semaphore(Mutex &m): init(); } +void Semaphore::init() +{ +#ifdef WIN32 + count=0; + sem=CreateSemaphore(0, 0, 32, 0); +#else + pthread_cond_init(&sem, 0); +#endif +} + +Semaphore::~Semaphore() +{ + if(own_mutex) + delete mutex; +#ifdef WIN32 + CloseHandle(sem); +#else + pthread_cond_destroy(&sem); +#endif +} + #ifdef WIN32 int Semaphore::signal() { @@ -97,25 +119,4 @@ int Semaphore::wait(const Time::TimeDelta &d) #endif } -Semaphore::~Semaphore() -{ - if(own_mutex) - delete mutex; -#ifdef WIN32 - CloseHandle(sem); -#else - pthread_cond_destroy(&sem); -#endif -} - -void Semaphore::init() -{ -#ifdef WIN32 - count=0; - sem=CreateSemaphore(0, 0, 32, 0); -#else - pthread_cond_init(&sem, 0); -#endif -} - } // namespace Msp