[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
This commit is contained in:
Joel Linn 2022-04-17 19:35:42 +02:00 committed by Rick Gibbed
parent 3b4dc7da3b
commit e3dd873892
1 changed files with 3 additions and 1 deletions

View File

@ -184,7 +184,9 @@ void TimerQueueWaitItem::Disarm() {
// once Disarm() has returned. // once Disarm() has returned.
while (!state_.compare_exchange_weak(state, State::kDisarmed, while (!state_.compare_exchange_weak(state, State::kDisarmed,
std::memory_order_acq_rel)) { 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; break;
} }
state = State::kIdle; state = State::kIdle;