From 223c40931e4f413431ab2f84d92c5f404e2d9cf2 Mon Sep 17 00:00:00 2001 From: "William A. Kennington III" Date: Fri, 19 Oct 2018 15:56:09 -0700 Subject: sdevent: Remove in favor of sdeventplus This change removes the one off sd-event wrapper from the project and uses the openbmc wide sdeventplus library. Change-Id: I8e042f875d06082e15606c7191a8073974f93990 Signed-off-by: William A. Kennington III --- src/callback.hpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'src/callback.hpp') diff --git a/src/callback.hpp b/src/callback.hpp index c79dcd0..0be7dc0 100644 --- a/src/callback.hpp +++ b/src/callback.hpp @@ -3,6 +3,9 @@ #include "data_types.hpp" #include +#include +#include +#include namespace phosphor { @@ -202,17 +205,19 @@ class ConditionalCallback : public Callback * callback. * * @tparam CallbackAccess - Provide access to callback group instances. - * @tparam TimerType - Delegated timer access methods. */ -template +template class DeferrableCallback : public ConditionalCallback { public: + using TimerType = + sdeventplus::utility::Timer; + DeferrableCallback() = delete; DeferrableCallback(const DeferrableCallback&) = delete; - DeferrableCallback(DeferrableCallback&&) = default; + DeferrableCallback(DeferrableCallback&&) = delete; DeferrableCallback& operator=(const DeferrableCallback&) = delete; - DeferrableCallback& operator=(DeferrableCallback&&) = default; + DeferrableCallback& operator=(DeferrableCallback&&) = delete; ~DeferrableCallback() = default; DeferrableCallback(const std::vector& graphEntry, Conditional& cond, @@ -227,28 +232,27 @@ class DeferrableCallback : public ConditionalCallback if (!timer) { timer = std::make_unique( + sdeventplus::Event::get_default(), // **INDENT-OFF** [ctx, this](auto& source) { this->ConditionalCallback::operator()(ctx); }); // **INDENT-ON** - timer->disable(); } if (this->condition()) { - if (!timer->enabled()) + if (!timer->isEnabled()) { // This is the first time the condition evaluated. // Start the countdown. - timer->update(timer->now() + delayInterval); - timer->enable(); + timer->restartOnce(delayInterval); } } else { // The condition did not evaluate. Stop the countdown. - timer->disable(); + timer->setEnabled(false); } } -- cgit v1.2.1