diff options
Diffstat (limited to 'abseil-cpp/absl/base/call_once.h')
-rw-r--r-- | abseil-cpp/absl/base/call_once.h | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/abseil-cpp/absl/base/call_once.h b/abseil-cpp/absl/base/call_once.h index 5b468af..08436ba 100644 --- a/abseil-cpp/absl/base/call_once.h +++ b/abseil-cpp/absl/base/call_once.h @@ -123,7 +123,7 @@ class SchedulingHelper { private: base_internal::SchedulingMode mode_; - bool guard_result_; + bool guard_result_ = false; }; // Bit patterns for call_once state machine values. Internal implementation @@ -177,15 +177,8 @@ void CallOnceImpl(std::atomic<uint32_t>* control, scheduling_mode) == kOnceInit) { base_internal::invoke(std::forward<Callable>(fn), std::forward<Args>(args)...); - // The call to SpinLockWake below is an optimization, because the waiter - // in SpinLockWait is waiting with a short timeout. The atomic load/store - // sequence is slightly faster than an atomic exchange: - // old_control = control->exchange(base_internal::kOnceDone, - // std::memory_order_release); - // We opt for a slightly faster case when there are no waiters, in spite - // of longer tail latency when there are waiters. - old_control = control->load(std::memory_order_relaxed); - control->store(base_internal::kOnceDone, std::memory_order_release); + old_control = + control->exchange(base_internal::kOnceDone, std::memory_order_release); if (old_control == base_internal::kOnceWaiter) { base_internal::SpinLockWake(control, true); } |