X-Git-Url: http://git.tdb.fi/?p=libs%2Fcore.git;a=blobdiff_plain;f=source%2Fcore%2Fsemaphore.cpp;h=9107a763aa0416e111d47390ffecda7cc0163c77;hp=9139ce1429b8e3ab484c38256925c7d1619ca83d;hb=fe77fc6b869a71bf94d501a0762579f4ddbc5094;hpb=e1ea831a640fba534e7e42e399f04cdf681ef8d3 diff --git a/source/core/semaphore.cpp b/source/core/semaphore.cpp index 9139ce1..9107a76 100644 --- a/source/core/semaphore.cpp +++ b/source/core/semaphore.cpp @@ -1,5 +1,5 @@ /* -This file is part of libmspframework +This file is part of libmspcore Copyright © 2006 Mikko Rasa, Mikkosoft Productions Distributed under the LGPL */ @@ -7,13 +7,14 @@ Distributed under the LGPL #include #include "semaphore.h" #include "../time/timestamp.h" +#include "../time/units.h" #include "../time/utils.h" namespace Msp { -#ifndef WIN32 int Semaphore::wait(const Time::TimeDelta &d) { +#ifndef WIN32 Time::TimeStamp ts=Time::now()+d; timespec timeout; @@ -21,13 +22,15 @@ int Semaphore::wait(const Time::TimeDelta &d) timeout.tv_nsec=(ts.raw()%1000000)*1000; MutexLock l(mutex); - int r=pthread_cond_timedwait(&cond, &mutex.mutex, &timeout); + int r=pthread_cond_timedwait(&sem, &mutex.mutex, &timeout); if(r==ETIMEDOUT) return 1; else if(r) return -1; return 0; -} +#else + return WaitForSingleObject(sem, (DWORD)(d/Time::usec))==WAIT_OBJECT_0; #endif +} } // namespace Msp