diff options
| author | William A. Kennington III <wak@google.com> | 2018-09-19 22:47:37 -0700 |
|---|---|---|
| committer | William A. Kennington III <wak@google.com> | 2018-09-19 23:23:31 -0700 |
| commit | 65da782a58c0f12a4f717c9700a3fb1bdb02ad8a (patch) | |
| tree | eb57df0d18c8890bd4a445f029145e6fa8c728cb | |
| parent | 59a4722de32831f31ec5d1dddfbc28ac90f24bdf (diff) | |
| download | sdeventplus-65da782a58c0f12a4f717c9700a3fb1bdb02ad8a.tar.gz sdeventplus-65da782a58c0f12a4f717c9700a3fb1bdb02ad8a.zip | |
source/time: Fix missing documentation
Documentation was accidentally left out of this class
Change-Id: I977caf9fbb716f2fcb3510f722712fdf695441b7
Signed-off-by: William A. Kennington III <wak@google.com>
| -rw-r--r-- | src/sdeventplus/source/time.hpp | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/sdeventplus/source/time.hpp b/src/sdeventplus/source/time.hpp index 28a42fb..14d4304 100644 --- a/src/sdeventplus/source/time.hpp +++ b/src/sdeventplus/source/time.hpp @@ -16,25 +16,77 @@ template <ClockId Id> class Time : public Base { public: + /** @brief Type used as the basis for absolute clock times */ using TimePoint = typename Clock<Id>::time_point; + /** @brief Type used to define the accuracy of the time source */ using Accuracy = SdEventDuration; + /** @brief Type of the user provided callback function */ using Callback = std::function<void(Time& source, TimePoint time)>; + /** @brief Creates a new time event source on the provided event loop + * + * @param[in] event - The event to attach the handler + * @param[in] time - Absolute time when the callback should be executed + * @param[in] accuracy - Optional amount of error tolerable in time source + * @param[in] callback - The function executed on event dispatch + */ Time(const Event& event, TimePoint time, Accuracy accuracy, Callback&& callback); + /** @brief Gets the absolute time when the time source expires + * + * @throws SdEventError for underlying sd_event errors + * @return Absolute time as an std::chrono::time_point + */ TimePoint get_time() const; + + /** @brief Sets the absolute time when the time source will expire + * + * @param[in] time - Absolute time as an std::chrono::time_point + * @throws SdEventError for underlying sd_event errors + */ void set_time(TimePoint time) const; + + /** @brief Gets the accuracy of the time source + * + * @throws SdEventError for underlying sd_event errors + * @return Accuracy as an std::chrono::duration + */ Accuracy get_accuracy() const; + + /** @brief Sets the accuracy of the time source + * + * @param[in] accuracy - Accuracy as std::chrono::duration + * @throws SdEventError for underlying sd_event errors + */ void set_accuracy(Accuracy accuracy) const; private: Callback callback; + /** @brief Returns a reference to the callback executed for this source + * + * @return A reference to the callback + */ const Callback& get_callback() const; + /** @brief Creates a new time source attached to the Event + * + * @param[in] event - The event to attach the handler + * @param[in] time - Absolute time when the callback should be executed + * @param[in] accuracy - Optional amount of error tolerable in time source + * @throws SdEventError for underlying sd_event errors + * @return A new sd_event_source + */ static sd_event_source* create_source(const Event& event, TimePoint time, Accuracy accuracy); + + /** @brief A wrapper around the callback that can be called from sd-event + * + * @param[in] source - The sd_event_source associated with the call + * @param[in] userdata - The provided userdata for the source + * @return 0 on success or a negative errno otherwise + */ static int timeCallback(sd_event_source* source, uint64_t usec, void* userdata); }; |

