Made the behaviour of Thread::Wait consistent across implementations when called from its owner thread
This commit is contained in:
parent
b0ebca9d29
commit
48e30ea0e3
@ -152,6 +152,8 @@ public :
|
||||
/// thread's function ends.
|
||||
/// Warning: if the thread function never ends, the calling
|
||||
/// thread will block forever.
|
||||
/// If this function is called from its owner thread, it
|
||||
/// returns without doing anything.
|
||||
///
|
||||
////////////////////////////////////////////////////////////
|
||||
void Wait();
|
||||
|
@ -57,7 +57,12 @@ ThreadImpl::~ThreadImpl()
|
||||
void ThreadImpl::Wait()
|
||||
{
|
||||
if (myThread)
|
||||
WaitForSingleObject(myThread, INFINITE);
|
||||
{
|
||||
// The following condition avoids a deadlock if Wait() is called from its
|
||||
// owner thread. This makes the behaviour consistent with the Unix implementation
|
||||
if (GetThreadId(myThread) != GetCurrentThreadId())
|
||||
WaitForSingleObject(myThread, INFINITE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user