From fb64c4f057eb73133cc05250761bcd465a84dba8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Aleksandrovi=C4=8D=20Klimov?= Date: Wed, 6 Nov 2024 11:37:02 +0100 Subject: [PATCH] Atomic#Atomic(): remove superfluous atomic write --- lib/base/atomic.hpp | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/lib/base/atomic.hpp b/lib/base/atomic.hpp index bf0aecdc6..855850336 100644 --- a/lib/base/atomic.hpp +++ b/lib/base/atomic.hpp @@ -12,7 +12,12 @@ namespace icinga { /** - * Extends std::atomic with an atomic constructor. + * Like std::atomic, but enforces usage of its only safe constructor. + * + * "The default-initialized std::atomic does not contain a T object, + * and its only valid uses are destruction and + * initialization by std::atomic_init, see LWG issue 2334." + * -- https://en.cppreference.com/w/cpp/atomic/atomic/atomic * * @ingroup base */ @@ -20,24 +25,12 @@ template class Atomic : public std::atomic { public: /** - * Like std::atomic#atomic, but operates atomically + * The only safe constructor of std::atomic#atomic * * @param desired Initial value */ inline Atomic(T desired) : std::atomic(desired) { - this->store(desired); - } - - /** - * Like std::atomic#atomic, but operates atomically - * - * @param desired Initial value - * @param order Initial store operation's memory order - */ - inline Atomic(T desired, std::memory_order order) : std::atomic(desired) - { - this->store(desired, order); } };