From e3dd8738921aa5074d84475b6ed157dfac573bbd Mon Sep 17 00:00:00 2001 From: Joel Linn Date: Sun, 17 Apr 2022 19:35:42 +0200 Subject: [PATCH] [Base] Fix wait for callback return - If wait item has disarmed itself and is then disarmed by another thread, still wait for the callback to return to meet guaratees --- src/xenia/base/threading_timer_queue.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/xenia/base/threading_timer_queue.cc b/src/xenia/base/threading_timer_queue.cc index ee4e6d751..79546b9d6 100644 --- a/src/xenia/base/threading_timer_queue.cc +++ b/src/xenia/base/threading_timer_queue.cc @@ -184,7 +184,9 @@ void TimerQueueWaitItem::Disarm() { // once Disarm() has returned. while (!state_.compare_exchange_weak(state, State::kDisarmed, std::memory_order_acq_rel)) { - if (state == State::kInCallbackSelfDisarmed || state == State::kDisarmed) { + if (state == State::kDisarmed) { + // Do not break for kInCallbackSelfDisarmed and keep spinning in order to + // meet guarantees break; } state = State::kIdle;