diff --git a/src/snmalloc/ds/aba.h b/src/snmalloc/ds/aba.h index 51c4470..f14cc9e 100644 --- a/src/snmalloc/ds/aba.h +++ b/src/snmalloc/ds/aba.h @@ -141,7 +141,7 @@ namespace snmalloc class ABA { std::atomic ptr = nullptr; - std::atomic_flag lock = ATOMIC_FLAG_INIT; + std::atomic lock{false}; public: // This method is used in Verona @@ -154,7 +154,7 @@ namespace snmalloc Cmp read() { - while (lock.test_and_set(std::memory_order_acquire)) + while (lock.exchange(true, std::memory_order_acquire)) Aal::pause(); # if !defined(NDEBUG) && !defined(SNMALLOC_DISABLE_ABA_VERIFY) @@ -184,7 +184,7 @@ namespace snmalloc ~Cmp() { - parent->lock.clear(std::memory_order_release); + parent->lock.store(false, std::memory_order_release); # if !defined(NDEBUG) && !defined(SNMALLOC_DISABLE_ABA_VERIFY) operation_in_flight = false; # endif diff --git a/src/snmalloc/mem/pooled.h b/src/snmalloc/mem/pooled.h index 51fc351..086cd22 100644 --- a/src/snmalloc/mem/pooled.h +++ b/src/snmalloc/mem/pooled.h @@ -24,25 +24,25 @@ namespace snmalloc std::atomic next{nullptr}; /// Used by the pool to keep the list of all entries ever created. capptr::Alloc list_next; - std::atomic_flag in_use = ATOMIC_FLAG_INIT; + std::atomic in_use{false}; public: void set_in_use() { - if (in_use.test_and_set()) + if (in_use.exchange(true)) error("Critical error: double use of Pooled Type!"); } void reset_in_use() { - in_use.clear(); + in_use.store(false); } bool debug_is_in_use() { - bool result = in_use.test_and_set(); + bool result = in_use.exchange(true); if (!result) - in_use.clear(); + in_use.store(false); return result; } };