2
0
mirror of https://github.com/boostorg/thread.git synced 2026-01-28 19:52:10 +00:00

Fixed time precision bugs. Switched to Interlocked* methods for once.

[SVN r14867]
This commit is contained in:
William E. Kempf
2002-08-15 00:05:54 +00:00
parent 391de20ae0
commit 75c83fed96
11 changed files with 130 additions and 61 deletions

View File

@@ -191,14 +191,12 @@ void thread::join()
void thread::sleep(const xtime& xt)
{
for (;;)
for (int foo=0; foo < 5; ++foo)
{
#if defined(BOOST_HAS_WINTHREADS)
int milliseconds;
to_duration(xt, milliseconds);
Sleep(milliseconds);
xtime xt2;
xtime_get(&xt2, TIME_UTC);
#elif defined(BOOST_HAS_PTHREADS)
# if defined(BOOST_HAS_PTHREAD_DELAY_NP)
timespec ts;
@@ -226,7 +224,9 @@ void thread::sleep(const xtime& xt)
AbsoluteTime sWakeTime(DurationToAbsolute(lMicroseconds));
threads::mac::detail::safe_delay_until(&sWakeTime);
#endif
if (xtime_cmp(xt, xt2) >= 0)
xtime cur;
xtime_get(&cur, TIME_UTC);
if (xtime_cmp(xt, cur) <= 0)
return;
}
}