X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcore%2Fsemaphore.cpp;h=bd1180b805b2701231e7833414717ea8bd7a9802;hb=c76bd823b81d723d8cd4531631a4b18544f1981a;hp=b9e7080cb04ea2b6e4808de5de658f1400322708;hpb=521cf1db00f8ce2d9f9494dca503d6c17d89ac2f;p=libs%2Fcore.git diff --git a/source/core/semaphore.cpp b/source/core/semaphore.cpp index b9e7080..bd1180b 100644 --- a/source/core/semaphore.cpp +++ b/source/core/semaphore.cpp @@ -4,7 +4,10 @@ This file is part of libmspcore Copyright © 2006 Mikko Rasa, Mikkosoft Productions Distributed under the LGPL */ + +#ifndef WIN32 #include +#endif #include #include "semaphore.h" #include "../time/timestamp.h" @@ -27,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() { @@ -95,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