2 This file is part of libmspcore
3 Copyright © 2006 Mikko Rasa, Mikkosoft Productions
4 Distributed under the LGPL
9 #include "../time/timestamp.h"
10 #include "../time/units.h"
11 #include "../time/utils.h"
15 int Semaphore::wait(const Time::TimeDelta &d)
18 Time::TimeStamp ts=Time::now()+d;
21 timeout.tv_sec=ts.raw()/1000000;
22 timeout.tv_nsec=(ts.raw()%1000000)*1000;
25 int r=pthread_cond_timedwait(&sem, &mutex.mutex, &timeout);
32 return WaitForSingleObject(sem, (DWORD)(d/Time::usec))==WAIT_OBJECT_0;