X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Ftime%2Futils.cpp;h=7da0aede047aab2e9f2a839005879a61f187df78;hb=62a984b46e08740d19cb055f01be3365982f6b9d;hp=cd2e70f3b88451ad4c1169421e5ffa78434c69aa;hpb=f5951e7166dfd7028b95d7c780406f65afc5cdfc;p=libs%2Fcore.git diff --git a/source/time/utils.cpp b/source/time/utils.cpp index cd2e70f..7da0aed 100644 --- a/source/time/utils.cpp +++ b/source/time/utils.cpp @@ -1,16 +1,11 @@ -/* $Id$ - -This file is part of libmspcore -Copyright © 2006-2008 Mikko Rasa, Mikkosoft Productions -Distributed under the LGPL -*/ - #ifdef WIN32 #include #else #include #include +#include #endif +#include #include "datetime.h" #include "timedelta.h" #include "timestamp.h" @@ -78,14 +73,15 @@ TimeDelta get_cpu_time() /** Sleeps for the given time. */ -int sleep(const TimeDelta &d) +void sleep(const TimeDelta &d) { #ifndef WIN32 timespec ts = d; - return nanosleep(&ts, 0); + while(nanosleep(&ts, 0)==-1) + if(errno!=EINTR) + throw system_error("nanosleep"); #else Sleep((DWORD)(d/msec)); - return 0; #endif }