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

@@ -195,23 +195,35 @@ bool recursive_timed_mutex::do_trylock()
bool recursive_timed_mutex::do_timedlock(const xtime& xt)
{
int milliseconds;
to_duration(xt, milliseconds);
for (;;)
{
int milliseconds;
to_duration(xt, milliseconds);
unsigned int res = 0;
res = WaitForSingleObject(reinterpret_cast<HANDLE>(m_mutex), milliseconds);
assert(res != WAIT_FAILED && res != WAIT_ABANDONED);
unsigned int res = 0;
res = WaitForSingleObject(reinterpret_cast<HANDLE>(m_mutex), milliseconds);
assert(res != WAIT_FAILED && res != WAIT_ABANDONED);
if (res == WAIT_OBJECT_0)
{
if (++m_count > 1)
{
res = ReleaseMutex(reinterpret_cast<HANDLE>(m_mutex));
assert(res);
}
return true;
}
return false;
if (res == WAIT_TIMEOUT)
{
xtime cur;
xtime_get(&cur, TIME_UTC);
if (xtime_cmp(xt, cur) > 0)
continue;
}
if (res == WAIT_OBJECT_0)
{
if (++m_count > 1)
{
res = ReleaseMutex(reinterpret_cast<HANDLE>(m_mutex));
assert(res);
}
return true;
}
return false;
}
}
void recursive_timed_mutex::do_unlock()