diff options
| author | William A. Kennington III <wak@google.com> | 2018-10-30 13:21:13 -0700 |
|---|---|---|
| committer | William A. Kennington III <wak@google.com> | 2018-10-30 13:23:25 -0700 |
| commit | 08ebb3993a2b5a82d0a5ead29a649c95632f7c64 (patch) | |
| tree | d545f9f1f446f9dc3ce5806823b75109d089c3dc /src | |
| parent | a5f8596add59b7ba5716abe5b0caba21ed84a0f7 (diff) | |
| download | sdeventplus-08ebb3993a2b5a82d0a5ead29a649c95632f7c64.tar.gz sdeventplus-08ebb3993a2b5a82d0a5ead29a649c95632f7c64.zip | |
utility/timer: Implement callback setting
All of the other classes that take callbacks support having the callback
updated.
Tested:
Builds and passed through the unit test suite.
Change-Id: I0efcd074523fa6ec0cc84c7a930346dd9340f7ec
Signed-off-by: William A. Kennington III <wak@google.com>
Diffstat (limited to 'src')
| -rw-r--r-- | src/sdeventplus/utility/timer.cpp | 6 | ||||
| -rw-r--r-- | src/sdeventplus/utility/timer.hpp | 6 |
2 files changed, 12 insertions, 0 deletions
diff --git a/src/sdeventplus/utility/timer.cpp b/src/sdeventplus/utility/timer.cpp index 2f28257..242f5d6 100644 --- a/src/sdeventplus/utility/timer.cpp +++ b/src/sdeventplus/utility/timer.cpp @@ -55,6 +55,12 @@ Timer<Id>::Timer(const Event& event, Callback&& callback, } template <ClockId Id> +void Timer<Id>::set_callback(Callback&& callback) +{ + this->callback = std::move(callback); +} + +template <ClockId Id> const Event& Timer<Id>::get_event() const { return timeSource.get_event(); diff --git a/src/sdeventplus/utility/timer.hpp b/src/sdeventplus/utility/timer.hpp index e45cf46..5d36458 100644 --- a/src/sdeventplus/utility/timer.hpp +++ b/src/sdeventplus/utility/timer.hpp @@ -61,6 +61,12 @@ class Timer typename source::Time<Id>::Accuracy accuracy = std::chrono::milliseconds{1}); + /** @brief Sets the callback + * + * @param[in] callback - The function executed on timer elapse + */ + void set_callback(Callback&& callback); + /** @brief Gets the associated Event object * * @return The Event |

