Base module

Idler

Asynchronous type that triggers callbacks when the event loop is idle.

Idler

#include <icy/idler.h>

Inherits: Runner

Asynchronous type that triggers callbacks when the event loop is idle.

This class inherits the [Runner](icy-Runner.html#runner) interface and may be used with any implementation that's powered by an asynchronous [Runner](icy-Runner.html#runner).

Public Methods

ReturnNameDescription
IdlerCreate the idler bound to loop without starting it.
Idler inline explicitCreate and immediately start the idler on the default loop.
Idler inline explicitCreate and immediately start the idler on the given loop.
voidstart inlineStart the idler, invoking func (with args) on every idle iteration.
voidstart virtualStart the idler with a type-erased callback (implements [Runner::start](icy-Runner.html#start-3)).
uv::Handle< uv_idle_t > &handle#### Returns

Idler

Idler(uv::Loop * loop)

Create the idler bound to loop without starting it.

Parameters

  • loop Event loop to associate with. Defaults to the process-wide default loop.

Idler

inline explicit

template<typename Function, typename... Args> inline explicit Idler(Function && func, Args &&... args)

Create and immediately start the idler on the default loop.

Parameters

  • func Callable invoked on every idle iteration.

  • args Arguments forwarded to func.


Idler

inline explicit

template<typename Function, typename... Args> inline explicit Idler(uv::Loop * loop, Function && func, Args &&... args)

Create and immediately start the idler on the given loop.

Parameters

  • loop Event loop to associate with.

  • func Callable invoked on every idle iteration.

  • args Arguments forwarded to func.


start

inline

template<typename Function, typename... Args> inline void start(Function && func, Args &&... args)

Start the idler, invoking func (with args) on every idle iteration.

The idler always runs in repeating mode; cancel via [Runner::cancel()](icy-Runner.html#cancel-2). Throws std::logic_error if the handle is already active or the runner context reports it is still running.

Parameters

  • func Callable invoked each time the event loop is idle.

  • args Arguments forwarded to func on each invocation.


start

virtual

virtual void start(std::function< void()> func)

Start the idler with a type-erased callback (implements [Runner::start](icy-Runner.html#start-3)).

Parameters

  • func Callback invoked on every idle iteration.

handle

uv::Handle< uv_idle_t > & handle()

Returns

Reference to the underlying uv_idle_t handle wrapper.

Protected Attributes

ReturnNameDescription
uv::Handle< uv_idle_t >_handle

_handle

uv::Handle< uv_idle_t > _handle

Protected Methods

ReturnNameDescription
voidinit virtualInitialize the underlying uv_idle_t handle and unref it from the loop.
boolasync virtual const#### Returns

init

virtual

virtual void init()

Initialize the underlying uv_idle_t handle and unref it from the loop.


async

virtual const

virtual bool async() const

Returns

false; the idler is event-loop-driven, not thread-based.