#include <sys/time.h>
#include <cerrno>
#endif
+#include <msp/time/rawtime_private.h>
#include <msp/time/timestamp.h>
#include <msp/time/units.h>
#include <msp/time/utils.h>
throw system_error("Semaphore::wait");
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)
#include "rawtime.h"
+#include "rawtime_private.h"
namespace Msp {
namespace Time {
#ifndef MSP_TIME_RAWTIME_H_
#define MSP_TIME_RAWTIME_H_
-#ifndef WIN32
-#include <sys/time.h>
-#endif
-
namespace Msp {
namespace Time {
typedef long long RawTime;
#endif
-#ifndef WIN32
-// Internal conversion utilities, not intended for public use
-timeval rawtime_to_timeval(RawTime);
-timespec rawtime_to_timespec(RawTime);
-#endif
-
} // namespace Time
} // namespace Msp
--- /dev/null
+#ifndef MSP_TIME_RAWTIME_PRIVATE_H_
+#define MSP_TIME_RAWTIME_PRIVATE_H_
+
+#ifndef WIN32
+#include <sys/time.h>
+#endif
+#include "rawtime.h"
+
+namespace Msp {
+namespace Time {
+
+#ifndef WIN32
+// Internal conversion utilities, not intended for public use
+timeval rawtime_to_timeval(RawTime);
+timespec rawtime_to_timespec(RawTime);
+#endif
+
+} // namespace Time
+} // namespace Msp
+
+#endif
bool operator==(const TimeDelta &t) const { return usec==t.usec; }
bool operator!=(const TimeDelta &t) const { return usec!=t.usec; }
-#ifndef WIN32
- operator timeval() const { return rawtime_to_timeval(usec); }
- operator timespec() const { return rawtime_to_timespec(usec); }
-#endif
-
operator const void *() const { return usec ? this : 0; }
};
operator const void *() const { return usec>0 ? this : 0; }
-#ifndef WIN32
- operator timeval() const { return rawtime_to_timeval(usec); }
- operator timespec() const { return rawtime_to_timespec(usec); }
-#endif
-
static TimeStamp from_unixtime(time_t t) { return TimeStamp(t*1000000LL); }
};
#endif
#include <msp/core/systemerror.h>
#include "datetime.h"
+#include "rawtime_private.h"
#include "timedelta.h"
#include "timestamp.h"
#include "units.h"
void sleep(const TimeDelta &d)
{
#ifndef WIN32
- timespec ts = d;
+ timespec ts = rawtime_to_timespec(d.raw());
while(nanosleep(&ts, 0)==-1)
if(errno!=EINTR)
throw system_error("nanosleep");