--- /dev/null
+/* Icinga 2 | (c) 2019 Icinga GmbH | GPLv2+ */
+
+#ifndef ATOMIC_H
+#define ATOMIC_H
+
+#include <atomic>
+
+namespace icinga
+{
+
+/**
+ * Extends std::atomic with an atomic constructor.
+ *
+ * @ingroup base
+ */
+template<class T>
+class Atomic : public std::atomic<T> {
+public:
+ /**
+ * Like std::atomic#atomic, but operates atomically
+ *
+ * @param desired Initial value
+ */
+ inline Atomic(T 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)
+ {
+ this->store(desired, order);
+ }
+};
+
+}
+
+#endif /* ATOMIC_H */
#include "config/configcompiler.hpp"
#include "config/configcompilercontext.hpp"
#include "config/configitembuilder.hpp"
+#include "base/atomic.hpp"
#include "base/defer.hpp"
#include "base/logger.hpp"
#include "base/application.hpp"
#include "base/scriptglobal.hpp"
#include "base/context.hpp"
#include "config.h"
-#include <atomic>
#include <cstdint>
#include <cstring>
#include <boost/program_options.hpp>
pid_t l_UmbrellaPid = 0;
// Whether the umbrella process allowed us to continue working beyond config validation
-static std::atomic<bool> l_AllowedToWork (false);
+static Atomic<bool> l_AllowedToWork (false);
#endif /* _WIN32 */
/**
})();
// The PID of the seemless worker currently being started by StartUnixWorker()
-static std::atomic<pid_t> l_CurrentlyStartingUnixWorkerPid (-1);
+static Atomic<pid_t> l_CurrentlyStartingUnixWorkerPid (-1);
// The state of the seemless worker currently being started by StartUnixWorker()
-static std::atomic<UnixWorkerState> l_CurrentlyStartingUnixWorkerState (UnixWorkerState::Pending);
+static Atomic<UnixWorkerState> l_CurrentlyStartingUnixWorkerState (UnixWorkerState::Pending);
// The last temination signal we received
-static std::atomic<int> l_TermSignal (-1);
+static Atomic<int> l_TermSignal (-1);
// Whether someone requested to re-load config (and we didn't handle that request, yet)
-static std::atomic<bool> l_RequestedReload (false);
+static Atomic<bool> l_RequestedReload (false);
// Whether someone requested to re-open logs (and we didn't handle that request, yet)
-static std::atomic<bool> l_RequestedReopenLogs (false);
+static Atomic<bool> l_RequestedReopenLogs (false);
/**
* Umbrella process' signal handlers
#ifdef HAVE_SYSTEMD
// When we last notified the watchdog.
-static std::atomic<double> l_LastNotifiedWatchdog (0);
+static Atomic<double> l_LastNotifiedWatchdog (0);
/**
* Notify the watchdog if not notified during the last 2.5s.