We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6673570 commit 2e82cf7Copy full SHA for 2e82cf7
api/include/opentelemetry/common/spin_lock_mutex.h
@@ -82,8 +82,7 @@ class SpinLockMutex
82
*/
83
bool try_lock() noexcept
84
{
85
- return !flag_.load(std::memory_order_relaxed) &&
86
- !flag_.exchange(true, std::memory_order_acquire);
+ return !flag_.exchange(true, std::memory_order_acquire);
87
}
88
89
/**
@@ -95,13 +94,9 @@ class SpinLockMutex
95
94
96
void lock() noexcept
97
98
- for (;;)
+ // Try once
+ while (!try_lock())
99
100
- // Try once
101
- if (!flag_.exchange(true, std::memory_order_acquire))
102
- {
103
- return;
104
- }
105
// Spin-Fast (goal ~10ns)
106
for (std::size_t i = 0; i < SPINLOCK_FAST_ITERATIONS; ++i)
107
0 commit comments