diff options
author | William A. Kennington III <wak@google.com> | 2018-10-19 15:56:09 -0700 |
---|---|---|
committer | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2018-12-06 14:00:26 +0000 |
commit | 223c40931e4f413431ab2f84d92c5f404e2d9cf2 (patch) | |
tree | fae46d08b8e00a2f0d34b62638ab090cd3831c3d /src/callback.hpp | |
parent | ecf8910c014b94c688d08fa856cd22ec365583fa (diff) | |
download | phosphor-dbus-monitor-223c40931e4f413431ab2f84d92c5f404e2d9cf2.tar.gz phosphor-dbus-monitor-223c40931e4f413431ab2f84d92c5f404e2d9cf2.zip |
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 <wak@google.com>
Diffstat (limited to 'src/callback.hpp')
-rw-r--r-- | src/callback.hpp | 22 |
1 files changed, 13 insertions, 9 deletions
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 <chrono> +#include <sdeventplus/clock.hpp> +#include <sdeventplus/event.hpp> +#include <sdeventplus/utility/timer.hpp> 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 <typename CallbackAccess, typename TimerType> +template <typename CallbackAccess> class DeferrableCallback : public ConditionalCallback<CallbackAccess> { public: + using TimerType = + sdeventplus::utility::Timer<sdeventplus::ClockId::Monotonic>; + 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<size_t>& graphEntry, Conditional& cond, @@ -227,28 +232,27 @@ class DeferrableCallback : public ConditionalCallback<CallbackAccess> if (!timer) { timer = std::make_unique<TimerType>( + sdeventplus::Event::get_default(), // **INDENT-OFF** [ctx, this](auto& source) { this->ConditionalCallback<CallbackAccess>::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); } } |