mirror of
https://github.com/SFML/SFML.git
synced 2024-11-29 06:41:05 +08:00
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.
|
/// thread's function ends.
|
||||||
/// Warning: if the thread function never ends, the calling
|
/// Warning: if the thread function never ends, the calling
|
||||||
/// thread will block forever.
|
/// thread will block forever.
|
||||||
|
/// If this function is called from its owner thread, it
|
||||||
|
/// returns without doing anything.
|
||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void Wait();
|
void Wait();
|
||||||
|
@ -57,7 +57,12 @@ ThreadImpl::~ThreadImpl()
|
|||||||
void ThreadImpl::Wait()
|
void ThreadImpl::Wait()
|
||||||
{
|
{
|
||||||
if (myThread)
|
if (myThread)
|
||||||
|
{
|
||||||
|
// 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);
|
WaitForSingleObject(myThread, INFINITE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user