Idler
Idler
#include <icy/idler.h>class IdlerDefined in src/base/include/icy/idler.h:31
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).
List of all members
| Name | Kind | Owner |
|---|---|---|
Idler | function | Declared here |
Idler | function | Declared here |
Idler | function | Declared here |
start | function | Declared here |
start | function | Declared here |
~Idler | function | Declared here |
handle | function | Declared here |
_handle | variable | Declared here |
init | function | Declared here |
async | function | Declared here |
Runner | function | Inherited from Runner |
~Runner | function | Inherited from Runner |
start | function | Inherited from Runner |
running | function | Inherited from Runner |
cancel | function | Inherited from Runner |
cancelled | function | Inherited from Runner |
repeating | function | Inherited from Runner |
setRepeating | function | Inherited from Runner |
async | function | Inherited from Runner |
tid | function | Inherited from Runner |
waitForExit | function | Inherited from Runner |
_context | variable | Inherited from Runner |
Runner | function | Inherited from Runner |
operator= | function | Inherited from Runner |
Runner | function | Inherited from Runner |
operator= | function | Inherited from Runner |
Inherited from Runner
| Kind | Name | Description |
|---|---|---|
function | Runner | |
function | ~Runner virtual | |
function | start virtual | Starts the asynchronous context with the given callback. The callback must remain valid for the lifetime of the [Runner](icy-Runner.html#runner). |
function | running const | Returns true if the async context is currently running. |
function | cancel | Signals the async context to stop at the earliest opportunity. |
function | cancelled const | Returns true if the context has been cancelled. The implementation is responsible for exiting as soon as possible after cancellation. |
function | repeating const | Returns true if the runner is in repeating mode. |
function | setRepeating | Enables or disables repeating mode. When repeating, the target function is invoked repeatedly until [cancel()](icy-Runner.html#cancel-2) is called. This normalizes behaviour across thread-based and event-loop-based [Runner](icy-Runner.html#runner) implementations. Must be called before [start()](icy-Runner.html#start-3). |
function | async virtual const | Returns true if the implementation is thread-based. |
function | tid const | Returns the native thread ID of the thread running the async context. |
function | waitForExit | Blocks until the async context exits or the timeout elapses. The context should be cancelled before calling this method. Must be called from outside the runner's own thread to avoid deadlock. |
variable | _context | Shared pointer to the internal Context. |
function | Runner | NonCopyable and NonMovable. |
function | operator= | Deleted assignment operator. |
function | Runner | Deleted constructor. |
function | operator= | Deleted assignment operator. |
Public Methods
| Return | Name | Description |
|---|---|---|
Idler | Create the idler bound to loop without starting it. | |
Idler inline explicit | Create and immediately start the idler on the default loop. | |
Idler inline explicit | Create and immediately start the idler on the given loop. | |
void | start inline | Start the idler, invoking func (with args) on every idle iteration. |
void | start virtual override | Start the idler with a type-erased callback (implements [Runner::start](icy-Runner.html#start-3)). |
uv::Handle< uv_idle_t > & | handle |
Idler
Idler(uv::Loop * loop = uv::defaultLoop())Defined in src/base/include/icy/idler.h:37
Create the idler bound to loop without starting it.
Parameters
loopEvent 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)Defined in src/base/include/icy/idler.h:44
Create and immediately start the idler on the default loop.
Parameters
funcCallable invoked on every idle iteration.argsArguments forwarded tofunc.
Idler
inline explicit
template<typename Function, typename... Args> inline explicit Idler(uv::Loop * loop, Function && func, Args &&... args)Defined in src/base/include/icy/idler.h:57
Create and immediately start the idler on the given loop.
Parameters
loopEvent loop to associate with.funcCallable invoked on every idle iteration.argsArguments forwarded tofunc.
start
inline
template<typename Function, typename... Args> inline void start(Function && func, Args &&... args)Defined in src/base/include/icy/idler.h:73
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
funcCallable invoked each time the event loop is idle.argsArguments forwarded tofuncon each invocation.
start
virtual override
virtual void start(std::function< void()> func) overrideDefined in src/base/include/icy/idler.h:118
Start the idler with a type-erased callback (implements [Runner::start](icy-Runner.html#start-3)).
Parameters
funcCallback invoked on every idle iteration.
Reimplements
handle
uv::Handle< uv_idle_t > & handle()Defined in src/base/include/icy/idler.h:123
Returns
Reference to the underlying uv_idle_t handle wrapper.
Protected Attributes
| Return | Name | Description |
|---|---|---|
uv::Handle< uv_idle_t > | _handle |
_handle
uv::Handle< uv_idle_t > _handleDefined in src/base/include/icy/idler.h:132
Protected Methods
| Return | Name | Description |
|---|---|---|
void | init virtual | Initialize the underlying uv_idle_t handle and unref it from the loop. |
bool | async virtual const override |
init
virtual
virtual void init()Defined in src/base/include/icy/idler.h:127
Initialize the underlying uv_idle_t handle and unref it from the loop.
async
virtual const override
virtual bool async() const overrideDefined in src/base/include/icy/idler.h:130
Returns
false; the idler is event-loop-driven, not thread-based.
