mirror of
https://github.com/abseil/abseil-cpp.git
synced 2026-06-04 12:07:05 +08:00
Stop using sleep timeouts for Linux futex-based SpinLock
Timeouts were once necessary when the SpinLock Unlock used an atomic store and could therefore have a race and a missed wakeup, however, the Unlock path now uses an atomic exchange, so the missed wakeup cannot happen. Fixes #1179 PiperOrigin-RevId: 452047517 Change-Id: I844944879b51b7f7ddac148e063a376cddd0d05a
This commit is contained in:
committed by
Copybara-Service
parent
ea78ded7a5
commit
a4cc270df1
@@ -57,13 +57,10 @@ static_assert(sizeof(std::atomic<uint32_t>) == sizeof(int),
|
||||
extern "C" {
|
||||
|
||||
ABSL_ATTRIBUTE_WEAK void ABSL_INTERNAL_C_SYMBOL(AbslInternalSpinLockDelay)(
|
||||
std::atomic<uint32_t> *w, uint32_t value, int loop,
|
||||
std::atomic<uint32_t> *w, uint32_t value, int,
|
||||
absl::base_internal::SchedulingMode) {
|
||||
absl::base_internal::ErrnoSaver errno_saver;
|
||||
struct timespec tm;
|
||||
tm.tv_sec = 0;
|
||||
tm.tv_nsec = absl::base_internal::SpinLockSuggestedDelayNS(loop);
|
||||
syscall(SYS_futex, w, FUTEX_WAIT | FUTEX_PRIVATE_FLAG, value, &tm);
|
||||
syscall(SYS_futex, w, FUTEX_WAIT | FUTEX_PRIVATE_FLAG, value, nullptr);
|
||||
}
|
||||
|
||||
ABSL_ATTRIBUTE_WEAK void ABSL_INTERNAL_C_SYMBOL(AbslInternalSpinLockWake)(
|
||||
|
||||
Reference in New Issue
Block a user