utility/timer: Allow floating
Change-Id: Id83f3e63beaf3247879b3e7d9c9cb048577646f4
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/src/sdeventplus/utility/timer.cpp b/src/sdeventplus/utility/timer.cpp
index 5c1d16a..9dcde82 100644
--- a/src/sdeventplus/utility/timer.cpp
+++ b/src/sdeventplus/utility/timer.cpp
@@ -51,6 +51,18 @@
}
template <ClockId Id>
+bool Timer<Id>::get_floating() const
+{
+ return timeSource.get_floating();
+}
+
+template <ClockId Id>
+void Timer<Id>::set_floating(bool b)
+{
+ return timeSource.set_floating(b);
+}
+
+template <ClockId Id>
bool Timer<Id>::hasExpired() const
{
return userdata->expired;
diff --git a/src/sdeventplus/utility/timer.hpp b/src/sdeventplus/utility/timer.hpp
index b29d41d..a378a46 100644
--- a/src/sdeventplus/utility/timer.hpp
+++ b/src/sdeventplus/utility/timer.hpp
@@ -85,6 +85,22 @@
*/
const Event& get_event() const;
+ /** @brief Determines the floating nature of the timer
+ *
+ * @throws SdEventError for underlying sd_event errors
+ * @return The enabled status of the timer
+ */
+ bool get_floating() const;
+
+ /** @brief Sets the floating nature of the timer
+ * If set to true, the timer will continue to run after the
+ * destruction of this handle.
+ *
+ * @param[in] b - Whether or not the timer should float
+ * @throws SdEventError for underlying sd_event errors
+ */
+ void set_floating(bool b);
+
/** @brief Has the timer expired since creation or reset of expiration
* state.
*