Class Timer::OsTimer

Nested Relationships

This class is a nested type of Class Timer.

Class Documentation

class OsTimer

This class will be DEPRECATED in the near future.

Public Functions

OsTimer(const units::Duration timeToWait, const std::function<void()> &callback) noexcept
OsTimer(const OsTimer&) = delete
OsTimer(OsTimer&&) = delete
OsTimer &operator=(const OsTimer&) = delete
OsTimer &operator=(OsTimer&&) = delete
virtual ~OsTimer() noexcept

D’tor.

cxx::expected<TimerError> start(const RunMode runMode, const CatchUpPolicy catchUpPolicy) noexcept

Starts the timer.

The callback is called by the operating system after the time has expired.

Note

Shall only be called when callback is given

Parameters:
  • runMode[in] can be a periodic timer if set to RunMode::PERIODIC or it runs just once when it is set to RunMode::ONCE

  • CatchUpPolicy[in] define behavior when callbackRuntime > timeToWait

cxx::expected<TimerError> stop() noexcept

Disarms the timer.

Note

Shall only be called when callback is given, guarantee after stop() call is callback is immediately called or never at all

cxx::expected<TimerError> restart(const units::Duration timeToWait, const RunMode runMode, const CatchUpPolicy catchUpPolicy) noexcept

Disarms the timer, assigns a new timeToWait value and arms the timer.

Note

Shall only be called when callback is given

Parameters:
  • runMode[in] periodic can be a periodic timer if set to RunMode::PERIODIC or once when in RunMode::ONCE

  • CatchUpPolicy[in] define behavior when callbackRuntime > timeToWait

cxx::expected<units::Duration, TimerError> timeUntilExpiration() noexcept

Note

Shall only be called when callback is given

cxx::expected<uint64_t, TimerError> getOverruns() noexcept

In case the callback is not immediately called by the operating system, getOverruns() returns the additional overruns that happended in the delay interval.

Note

Shall only be called when callback is given

bool hasError() const noexcept

Returns true if the construction of the object was successful.

TimerError getError() const noexcept

Returns the error that occured on constructing the object.

Public Static Functions

static void callbackHelper(sigval data) noexcept

Wrapper that can be registered with the operating system.