diff options
Diffstat (limited to 'watchdog.hpp')
-rw-r--r-- | watchdog.hpp | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/watchdog.hpp b/watchdog.hpp index efa413a..c9821db 100644 --- a/watchdog.hpp +++ b/watchdog.hpp @@ -3,10 +3,10 @@ #include "timer.hpp" #include <functional> -#include <map> #include <optional> #include <sdbusplus/bus.hpp> #include <sdbusplus/server/object.hpp> +#include <unordered_map> #include <utility> #include <xyz/openbmc_project/State/Watchdog/server.hpp> @@ -14,6 +14,7 @@ namespace phosphor { namespace watchdog { + namespace Base = sdbusplus::xyz::openbmc_project::State::server; using WatchdogInherits = sdbusplus::server::object::object<Base::Watchdog>; @@ -36,6 +37,11 @@ class Watchdog : public WatchdogInherits */ using TargetName = std::string; + /** @brief Type used to store the mapping of a Watchdog timeout + * action to a systemd target. + */ + using ActionTargetMap = std::unordered_map<Action, TargetName>; + /** @brief Type used to specify the parameters of a fallback watchdog */ struct Fallback @@ -47,18 +53,17 @@ class Watchdog : public WatchdogInherits /** @brief Constructs the Watchdog object * - * @param[in] bus - DBus bus to attach to. - * @param[in] objPath - Object path to attach to. - * @param[in] event - reference to sd_event unique pointer - * @param[in] actionTargets - map of systemd targets called on timeout + * @param[in] bus - DBus bus to attach to. + * @param[in] objPath - Object path to attach to. + * @param[in] event - reference to sd_event unique pointer + * @param[in] actionTargetMap - map of systemd targets called on timeout * @param[in] fallback */ Watchdog(sdbusplus::bus::bus& bus, const char* objPath, EventPtr& event, - std::map<Action, TargetName>&& actionTargets = - std::map<Action, TargetName>(), + ActionTargetMap&& actionTargetMap = {}, std::optional<Fallback>&& fallback = std::nullopt) : WatchdogInherits(bus, objPath), - bus(bus), actionTargets(std::move(actionTargets)), + bus(bus), actionTargetMap(std::move(actionTargetMap)), fallback(std::move(fallback)), timer(event, std::bind(&Watchdog::timeOutHandler, this)) { @@ -127,7 +132,7 @@ class Watchdog : public WatchdogInherits sdbusplus::bus::bus& bus; /** @brief Map of systemd units to be started when the timer expires */ - std::map<Action, TargetName> actionTargets; + ActionTargetMap actionTargetMap; /** @brief Fallback timer options */ std::optional<Fallback> fallback; |