From 2b25468ada7d5cdb33102ac516d75e37d711ee93 Mon Sep 17 00:00:00 2001 From: Tapish Date: Wed, 24 Jul 2024 11:00:39 +0200 Subject: [PATCH] Remove deprecated atomics --- redGrapes/util/atomic_list.hpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/redGrapes/util/atomic_list.hpp b/redGrapes/util/atomic_list.hpp index 0ff7b4b7..77320493 100644 --- a/redGrapes/util/atomic_list.hpp +++ b/redGrapes/util/atomic_list.hpp @@ -45,10 +45,10 @@ namespace redGrapes struct ItemControlBlock { bool volatile deleted; - std::shared_ptr prev; + std::atomic> prev; uintptr_t item_data_ptr; - ItemControlBlock(memory::Block blk) : deleted(false), item_data_ptr(blk.ptr) + ItemControlBlock(memory::Block blk) : deleted(false), prev(nullptr), item_data_ptr(blk.ptr) { /* put Item at front and initialize it * with the remaining memory region @@ -76,11 +76,11 @@ namespace redGrapes */ void skip_deleted_prev() { - std::shared_ptr p = std::atomic_load(&prev); + std::shared_ptr p = (&prev)->load(); while(p && p->deleted) - p = std::atomic_load(&p->prev); + p = (&p->prev)->load(); - std::atomic_store(&prev, p); + (&prev)->store(p); } Item* get() const @@ -90,7 +90,7 @@ namespace redGrapes }; Allocator alloc; - std::shared_ptr head; + std::atomic> head; size_t const chunk_capacity; /* keeps a single, predefined pointer @@ -256,7 +256,7 @@ namespace redGrapes */ MutBackwardIterator rbegin() const { - return MutBackwardIterator{std::atomic_load(&head)}; + return MutBackwardIterator{(&head)->load()}; } MutBackwardIterator rend() const @@ -266,7 +266,7 @@ namespace redGrapes ConstBackwardIterator crbegin() const { - return ConstBackwardIterator{std::atomic_load(&head)}; + return ConstBackwardIterator{(&head)->load()}; } ConstBackwardIterator crend() const @@ -297,9 +297,9 @@ namespace redGrapes bool append_successful = false; while(!append_successful) { - old_head = std::atomic_load(&head); - std::atomic_store(&new_head->prev, old_head); - append_successful = std::atomic_compare_exchange_strong(&head, &old_head, new_head); + old_head = (&head)->load(); + (&new_head->prev)->store(old_head); + append_successful = (&head)->compare_exchange_strong(&old_head, new_head); } return MutBackwardIterator{old_head}; @@ -312,7 +312,7 @@ namespace redGrapes std::shared_ptr expected(nullptr); std::shared_ptr const& desired = new_head; - return std::atomic_compare_exchange_strong(&head, &expected, desired); + return (&head)->compare_exchange_strong(&expected, desired); } };