diff options
author | Andreas Kling <kling@serenityos.org> | 2020-05-20 14:23:33 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-05-20 16:24:26 +0200 |
commit | 67cc7d09a29db33bfd3b873f195c10e850231f13 (patch) | |
tree | 974b058c5b2e968dd49bf84b6acf1b8539b02075 /AK | |
parent | 8876bfc3ac6b395828ab3616cc874971d5c01d6a (diff) | |
download | serenity-67cc7d09a29db33bfd3b873f195c10e850231f13.zip |
Revert "AK: Add AtomicRef, for atomically accesing a reference to a varaible"
This reverts commit aff594f1e790feff0cd7dda3e9f0ecd5573c51bf.
Diffstat (limited to 'AK')
-rw-r--r-- | AK/Atomic.h | 102 |
1 files changed, 0 insertions, 102 deletions
diff --git a/AK/Atomic.h b/AK/Atomic.h index 68d3b55ec9..f06eca1203 100644 --- a/AK/Atomic.h +++ b/AK/Atomic.h @@ -257,108 +257,6 @@ public: } }; -template <typename T> -class AtomicRef -{ - T* m_value { nullptr }; - -public: - AtomicRef() noexcept = delete; - AtomicRef(const AtomicRef&) = delete; - AtomicRef& operator=(const AtomicRef&) volatile = delete; - - AtomicRef(T* val) noexcept - : m_value(val) - { - } - - AtomicRef(T& val) noexcept - : m_value(&val) - { - } - - T exchange(T desired, MemoryOrder order = memory_order_seq_cst) volatile noexcept - { - return __atomic_exchange_n(m_value, desired, order); - } - - bool compare_exchange_strong(T& expected, T desired, MemoryOrder order = memory_order_seq_cst) volatile noexcept - { - // On failure, acquire the new value - if (order == memory_order_acq_rel || order == memory_order_release) - return __atomic_compare_exchange_n(m_value, &expected, desired, false, memory_order_acq_rel, memory_order_acquire); - else - return __atomic_compare_exchange_n(m_value, &expected, desired, false, order, order); - } - - T operator++() volatile noexcept - { - return fetch_add(1) + 1; - } - - T operator++(int) volatile noexcept - { - return fetch_add(1); - } - - T operator+=(T val) volatile noexcept - { - return fetch_add(val) + val; - } - - T fetch_add(T val, MemoryOrder order = memory_order_seq_cst) volatile noexcept - { - return __atomic_fetch_add(m_value, val, order); - } - - T operator--() volatile noexcept - { - return fetch_sub(1) - 1; - } - - T operator--(int) volatile noexcept - { - return fetch_sub(1); - } - - T operator-=(T val) volatile noexcept - { - return fetch_sub(val) - val; - } - - T fetch_sub(T val, MemoryOrder order = memory_order_seq_cst) volatile noexcept - { - return __atomic_fetch_sub(m_value, val, order); - } - - operator T*() const volatile noexcept - { - return load(); - } - - T load(MemoryOrder order = memory_order_seq_cst) const volatile noexcept - { - return __atomic_load_n(m_value, order); - } - - T operator=(T desired) volatile noexcept - { - store(desired); - return desired; - } - - void store(T desired, MemoryOrder order = memory_order_seq_cst) volatile noexcept - { - __atomic_store_n(&m_value, desired, order); - } - - bool is_lock_free() const volatile noexcept - { - return __atomic_is_lock_free(sizeof(*m_value), m_value); - } -}; - } using AK::Atomic; -using AK::AtomicRef; |