pw_sync_freertos: remove unnecessary atomic in InterruptSpinLock
Changes the internal InterruptSpinLock locked state to use a plain
bool instead of an atomic bool as an atomic is not necessary.
Change-Id: I15fec5bd99861361a2ddbea98192447d09d17e79
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/50464
Pigweed-Auto-Submit: Ewout van Bekkum <ewout@google.com>
Commit-Queue: Ewout van Bekkum <ewout@google.com>
Reviewed-by: Wyatt Hepler <hepler@google.com>
diff --git a/pw_sync_freertos/interrupt_spin_lock.cc b/pw_sync_freertos/interrupt_spin_lock.cc
index 656b05c..825afc4 100644
--- a/pw_sync_freertos/interrupt_spin_lock.cc
+++ b/pw_sync_freertos/interrupt_spin_lock.cc
@@ -27,15 +27,15 @@
taskENTER_CRITICAL();
}
// We can't deadlock here so crash instead.
- PW_CHECK(!native_type_.locked.load(std::memory_order_relaxed),
+ PW_CHECK(!native_type_.locked,
"Recursive InterruptSpinLock::lock() detected");
- native_type_.locked.store(true, std::memory_order_relaxed);
+ native_type_.locked = true;
}
bool InterruptSpinLock::try_lock() {
if (interrupt::InInterruptContext()) {
UBaseType_t saved_interrupt_mask = taskENTER_CRITICAL_FROM_ISR();
- if (native_type_.locked.load(std::memory_order_relaxed)) {
+ if (native_type_.locked) {
// Already locked, restore interrupts and bail out.
taskEXIT_CRITICAL_FROM_ISR(saved_interrupt_mask);
return false;
@@ -43,18 +43,18 @@
native_type_.saved_interrupt_mask = saved_interrupt_mask;
} else { // Task context
taskENTER_CRITICAL();
- if (native_type_.locked.load(std::memory_order_relaxed)) {
+ if (native_type_.locked) {
// ALready locked, restore interrupts and bail out.
taskEXIT_CRITICAL();
return false;
}
}
- native_type_.locked.store(true, std::memory_order_relaxed);
+ native_type_.locked = true;
return true;
}
void InterruptSpinLock::unlock() {
- native_type_.locked.store(false, std::memory_order_relaxed);
+ native_type_.locked = false;
if (interrupt::InInterruptContext()) {
taskEXIT_CRITICAL_FROM_ISR(native_type_.saved_interrupt_mask);
} else { // Task context