diff options
author | William A. Kennington III <wak@google.com> | 2018-10-30 19:00:27 -0700 |
---|---|---|
committer | William A. Kennington III <wak@google.com> | 2018-11-05 11:43:07 -0800 |
commit | 94fe1a0c83ba2d0dadc549b1d8afedf6478d2dcf (patch) | |
tree | d46070fc9ad670f751387f94c20e9fde90df89a0 /control/actions.cpp | |
parent | 122b843fdef01a66c602d1270d50b7db576e7167 (diff) | |
download | phosphor-fan-presence-94fe1a0c83ba2d0dadc549b1d8afedf6478d2dcf.tar.gz phosphor-fan-presence-94fe1a0c83ba2d0dadc549b1d8afedf6478d2dcf.zip |
control/zone: Refactor addTimer
Anything adding a timer uses roughly the same process of building the
event data and timer from the event group, actions, and timer config. We
can adjust the method to do this for all callers.
Tested:
Builds and passes unit tests.
Change-Id: I4013ff2f7bff65095a6e1db7075bc013da374f51
Signed-off-by: William A. Kennington III <wak@google.com>
Diffstat (limited to 'control/actions.cpp')
-rw-r--r-- | control/actions.cpp | 25 |
1 files changed, 1 insertions, 24 deletions
diff --git a/control/actions.cpp b/control/actions.cpp index 923b1cc..0267c10 100644 --- a/control/actions.cpp +++ b/control/actions.cpp @@ -33,30 +33,7 @@ Action call_actions_based_on_timer(TimerConf&& tConf, zone.findTimer(group, actions) == std::end(zone.getTimerEvents())) { - // Associate event data with timer - std::unique_ptr<EventData> eventData = - std::make_unique<EventData>( - group, - "", - nullptr, - actions - ); - // Create/start timer and associate event data with it - std::unique_ptr<util::Timer> timer = - std::make_unique<util::Timer>( - zone.getEventLoop(), - [&zone, - actions = &actions, - group = &group]() - { - zone.timerExpired(*group, *actions); - }); - if (!timer->running()) - { - timer->start(std::get<intervalPos>(tConf), - std::get<typePos>(tConf)); - } - zone.addTimer(std::move(eventData), std::move(timer)); + zone.addTimer(group, actions, tConf); } else { |