Invoke optional callback function on timer expiration
When the timer expires, it calls into it's own timeout
handler which matches with sd_event callback handler.
However, it is beneficial if the users of timer register
their own callback routine so that they can execute some
operations on timeout.
Change-Id: Ia88cb4e3c17f6dd8d4528fa193ec7927f083a92b
Signed-off-by: Vishwanatha Subbanna <vishwa@linux.vnet.ibm.com>
diff --git a/watchdog.hpp b/watchdog.hpp
index 47484af..1a7a410 100644
--- a/watchdog.hpp
+++ b/watchdog.hpp
@@ -5,7 +5,6 @@
#include <sdbusplus/server/object.hpp>
#include <xyz/openbmc_project/State/Watchdog/server.hpp>
#include "timer.hpp"
-
namespace phosphor
{
namespace watchdog
@@ -39,7 +38,7 @@
EventPtr& event) :
WatchdogInherits(bus, objPath),
bus(bus),
- timer(event)
+ timer(event, std::bind(&Watchdog::timeOutHandler, this))
{
// Nothing
}
@@ -86,6 +85,9 @@
/** @brief Contained timer object */
Timer timer;
+
+ /** @brief Optional Callback handler on timer expirartion */
+ void timeOutHandler();
};
} // namespace watchdog