Skip to content

iox::posix::Timer::OsTimer🔗

This class will be DEPRECATED in the near future. ## Public Functions

Name
void callbackHelper(sigval data)
Wrapper that can be registered with the operating system.
OsTimer(const units::Duration timeToWait, const std::function< void()> & callback)
OsTimer(const OsTimer & )
OsTimer(OsTimer && )
OsTimer & operator=(const OsTimer & )
OsTimer & operator=(OsTimer && )
virtual ~OsTimer()
D'tor.
cxx::expected< TimerError > start(const RunMode runMode, const CatchUpPolicy catchUpPolicy)
Starts the timer.
cxx::expected< TimerError > stop()
Disarms the timer.
cxx::expected< TimerError > restart(const units::Duration timeToWait, const RunMode runMode, const CatchUpPolicy catchUpPolicy)
Disarms the timer, assigns a new timeToWait value and arms the timer.
cxx::expected< units::Duration, TimerError > timeUntilExpiration()
cxx::expected< uint64_t, TimerError > getOverruns()
In case the callback is not immediately called by the operating system, getOverruns() returns the additional overruns that happended in the delay interval.
bool hasError() const
Returns true if the construction of the object was successful.
TimerError getError() const
Returns the error that occured on constructing the object.

Public Functions Documentation🔗

function callbackHelper🔗

static void callbackHelper(
    sigval data
)

Wrapper that can be registered with the operating system.

function OsTimer🔗

OsTimer(
    const units::Duration timeToWait,
    const std::function< void()> & callback
)

function OsTimer🔗

OsTimer(
    const OsTimer & 
)

function OsTimer🔗

OsTimer(
    OsTimer && 
)

function operator=🔗

OsTimer & operator=(
    const OsTimer & 
)

function operator=🔗

OsTimer & operator=(
    OsTimer && 
)

function ~OsTimer🔗

virtual ~OsTimer()

D'tor.

function start🔗

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

Starts the timer.

Parameters:

  • runMode can be a periodic timer if set to RunMode::PERIODIC or it runs just once when it is set to RunMode::ONCE
  • CatchUpPolicy define behavior when callbackRuntime > timeToWait

Note: Shall only be called when callback is given

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

function stop🔗

cxx::expected< TimerError > stop()

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

function restart🔗

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

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

Parameters:

  • runMode periodic can be a periodic timer if set to RunMode::PERIODIC or once when in RunMode::ONCE
  • CatchUpPolicy define behavior when callbackRuntime > timeToWait

Note: Shall only be called when callback is given

function timeUntilExpiration🔗

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

Note: Shall only be called when callback is given

function getOverruns🔗

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

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

function hasError🔗

bool hasError() const

Returns true if the construction of the object was successful.

function getError🔗

TimerError getError() const

Returns the error that occured on constructing the object.


Updated on 18 December 2023 at 13:11:42 CET