Atomic guard impromenents (#9473)
* Read atomic before doing CAS in the constructor. * Typo * Code style fix. Co-authored-by: Roman Slivinskyi <rsl@keepit.com>
This commit is contained in:
parent
ef390902ec
commit
c634f105e3
@ -12,7 +12,7 @@ class AtomicGuard {
|
||||
public:
|
||||
AtomicGuard(std::atomic_bool& b) : m_atomic(b) {
|
||||
bool exp = false;
|
||||
while (!m_atomic.compare_exchange_strong(exp, true)) {
|
||||
while (m_atomic.load(std::memory_order_relaxed) || !m_atomic.compare_exchange_strong(exp, true)) {
|
||||
exp = false;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user