X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcore%2Fsemaphore.cpp;h=06e8435c3a34212599a8ead8817d28073c4c26cc;hb=eeb6b89120ab259702f103da01bfd8c06f285e7b;hp=e923ca8835efb7e3e7b59e4afd2f6ec4e92c078e;hpb=967785734be5c3fc6f75da122c2d93ebbb338271;p=libs%2Fcore.git diff --git a/source/core/semaphore.cpp b/source/core/semaphore.cpp index e923ca8..06e8435 100644 --- a/source/core/semaphore.cpp +++ b/source/core/semaphore.cpp @@ -4,6 +4,7 @@ #include #include #endif +#include #include #include #include @@ -52,13 +53,13 @@ void Semaphore::signal() { #ifdef WIN32 if(!ReleaseSemaphore(priv->handle, 1, 0)) - throw system_error("Semaphore::signal"); + throw system_error("ReleaseSemaphore"); #else MutexLock mlock(priv->mutex); if(priv->countlimit) ++priv->count; if(int err = pthread_cond_signal(&priv->cond)) - throw system_error("Semaphore::signal", err); + throw system_error("pthread_cond_signal", err); #endif } @@ -67,12 +68,12 @@ void Semaphore::wait() #ifdef WIN32 DWORD ret = WaitForSingleObject(priv->handle, INFINITE); if(ret==WAIT_FAILED) - throw system_error("Semaphore::wait"); + throw system_error("WaitForSingleObject"); #else MutexLock mlock(priv->mutex); while(!priv->count) if(int err = pthread_cond_wait(&priv->cond, &priv->mutex.priv->mutex)) - throw system_error("Semaphore::wait", err); + throw system_error("pthread_cond_wait", err); --priv->count; #endif } @@ -82,14 +83,14 @@ bool Semaphore::wait(const Time::TimeDelta &d) #ifdef WIN32 DWORD ret = WaitForSingleObject(priv->handle, (DWORD)(d/Time::usec)); if(ret==WAIT_FAILED) - throw system_error("Semaphore::wait"); + throw system_error("WaitForSingleObject"); return ret==WAIT_OBJECT_0; #else - timespec timeout = Time::now()+d; + timespec timeout = Time::rawtime_to_timespec((Time::now()+d).raw()); int err = pthread_cond_timedwait(&priv->cond, &priv->mutex.priv->mutex, &timeout); if(err && err!=ETIMEDOUT) - throw system_error("Semaphore::wait", err); + throw system_error("pthread_cond_timedwait", err); return err==0; #endif }