aboutsummaryrefslogtreecommitdiffstats
path: root/common/atomic.h
diff options
context:
space:
mode:
Diffstat (limited to 'common/atomic.h')
-rw-r--r--common/atomic.h6
1 files changed, 5 insertions, 1 deletions
diff --git a/common/atomic.h b/common/atomic.h
index 51ddaa5d..8e75cb0e 100644
--- a/common/atomic.h
+++ b/common/atomic.h
@@ -41,7 +41,11 @@ public:
explicit atomic_unique_ptr(std::nullptr_t) noexcept { }
explicit atomic_unique_ptr(gsl::owner<T*> ptr) noexcept : mPointer{ptr} { }
explicit atomic_unique_ptr(std::unique_ptr<T>&& rhs) noexcept : mPointer{rhs.release()} { }
- ~atomic_unique_ptr() { if(auto ptr = mPointer.load(std::memory_order_relaxed)) D{}(ptr); }
+ ~atomic_unique_ptr()
+ {
+ if(auto ptr = mPointer.exchange(nullptr, std::memory_order_relaxed))
+ D{}(ptr);
+ }
atomic_unique_ptr& operator=(const atomic_unique_ptr&) = delete;
atomic_unique_ptr& operator=(std::nullptr_t) noexcept