2
0
mirror of https://github.com/boostorg/thread.git synced 2026-01-28 07:42:12 +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

@@ -145,12 +145,25 @@ bool timed_mutex::do_trylock()
bool timed_mutex::do_timedlock(const xtime& xt)
{
int milliseconds;
to_duration(xt, milliseconds);
unsigned int res = 0;
for (;;)
{
int milliseconds;
to_duration(xt, milliseconds);
unsigned int res = WaitForSingleObject(reinterpret_cast<HANDLE>(m_mutex), milliseconds);
assert(res != WAIT_FAILED && res != WAIT_ABANDONED);
return res == WAIT_OBJECT_0;
res = WaitForSingleObject(reinterpret_cast<HANDLE>(m_mutex), milliseconds);
assert(res != WAIT_FAILED && res != WAIT_ABANDONED);
if (res == WAIT_TIMEOUT)
{
xtime cur;
xtime_get(&cur, TIME_UTC);
if (xtime_cmp(xt, cur) > 0)
continue;
}
return res == WAIT_OBJECT_0;
}
}
void timed_mutex::do_unlock()