From a503b6222fc084cfb6554f9731de3d3105a92adb Mon Sep 17 00:00:00 2001 From: Sandy Carter Date: Mon, 21 Jan 2019 14:26:16 -0500 Subject: [PATCH] [threads linux] Free and signal suspended threads Give other threads access to initially suspended threads by signalling conditional variable before waiting for state to be changed again. --- src/xenia/base/threading_posix.cc | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/xenia/base/threading_posix.cc b/src/xenia/base/threading_posix.cc index bb45107e3..23653a968 100644 --- a/src/xenia/base/threading_posix.cc +++ b/src/xenia/base/threading_posix.cc @@ -916,17 +916,17 @@ void* PosixCondition::ThreadStartRoutine(void* parameter) { current_thread_ = thread; { std::unique_lock lock(thread->handle_.state_mutex_); - if (create_suspended) { - thread->handle_.state_ = State::kSuspended; - thread->handle_.state_signal_.wait(lock, [thread] { - return thread->handle_.state_ != State::kSuspended; - }); - } else { - thread->handle_.state_ = State::kRunning; - } + thread->handle_.state_ = + create_suspended ? State::kSuspended : State::kRunning; thread->handle_.state_signal_.notify_all(); } + if (create_suspended) { + std::unique_lock lock(thread->handle_.state_mutex_); + thread->handle_.state_signal_.wait( + lock, [thread] { return thread->handle_.state_ != State::kSuspended; }); + } + start_routine(); {