timerΒΆ

Periodic timeout support.

This module allows timeouts to be set for a callback to be called as soon as possible after some future time.

namespace eos

Functions

seconds_t now()

Monotonically increasing time in seconds.

Corresponds to the number of seconds since system boot plus an arbitrary offset. As such, this value does not permit derivation of a wallclock time (use time() from time.h for that).

Instead, now() provides a monotonically increasing value unaffected by leap seconds.

Variables

const seconds_t never

‘never’ represents a future time that now() can never reach.

class timeout_handler
#include <timer.h>

The ‘timeout_handler’ class manages a single instance of a timer.

To schedule a timeout, call timeout_time_is() using an absolute time greater than now(). When the timeout_time has been exceeded, on_timeout() is called and the timer is unset. To cancel a timer, set the timeout to the ‘never’ constant.

There are no guarantees that on_timeout() will be called exactly at the configured timeout, though we guarantee this will never be called *before* the configured timeout

Public Functions

timeout_handler(timeout_mgr * mgr)
virtual ~timeout_handler()
void timeout_time_is(seconds_t)

Sets the next time on_timeout() will be called.

The on_timeout() callback will be called as soon as possible after the provided time.

virtual void on_timeout() = 0

Returns the next timeout value.

Private Members

timer_internal * timer_

Friends

friend class timer_internal
class timeout_mgr

Public Functions

virtual ~timeout_mgr()

Protected Functions

virtual void init_handler(timeout_handler *) = 0
timeout_mgr()

Private Members

timeout_mgr

Friends

friend class timeout_handler

Previous topic

system

Next topic

tracing