diff options
Diffstat (limited to 'zencore/thread.cpp')
| -rw-r--r-- | zencore/thread.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/zencore/thread.cpp b/zencore/thread.cpp index e422d7ce3..3e40b6336 100644 --- a/zencore/thread.cpp +++ b/zencore/thread.cpp @@ -200,6 +200,12 @@ Event::Wait(int TimeoutMs) if (TimeoutMs >= 0) { std::unique_lock Lock(Inner->Mutex); + + if (Inner->bSet) + { + return true; + } + return Inner->CondVar.wait_for( Lock, std::chrono::milliseconds(TimeoutMs), @@ -208,7 +214,12 @@ Event::Wait(int TimeoutMs) } std::unique_lock Lock(Inner->Mutex); - Inner->CondVar.wait(Lock, [&] { return Inner->bSet; }); + + if (!Inner->bSet) + { + Inner->CondVar.wait(Lock, [&] { return Inner->bSet; }); + } + return true; #endif } |