Idler
#include <icy/idler.h>
class IdlerDefined in src/base/include/icy/idler.h:31
- Inherits
Runner
This class inherits the Runner interface and may be used with any implementation that's powered by an asynchronous 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. |
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() is called. This normalizes behaviour across thread-based and event-loop-based Runner implementations. Must be called before start(). |
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). |
~Idler virtual | Defaulted destructor. | |
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
| Parameter | Type | Description |
|---|---|---|
loop | uv::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)Defined in src/base/include/icy/idler.h:44
Create and immediately start the idler on the default loop.
Parameters
| Parameter | Type | Description |
|---|---|---|
func | Function && | Callable invoked on every idle iteration. |
args | Args &&... | Arguments forwarded to func. |
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
| Parameter | Type | Description |
|---|---|---|
loop | uv::Loop * | Event loop to associate with. |
func | Function && | Callable invoked on every idle iteration. |
args | Args &&... | Arguments forwarded to func. |
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(). Throws std::logic_error if the handle is already active or the runner context reports it is still running.
Parameters
| Parameter | Type | Description |
|---|---|---|
func | Function && | Callable invoked each time the event loop is idle. |
args | Args &&... | Arguments forwarded to func on 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).
Reimplements
Parameters
| Parameter | Type | Description |
|---|---|---|
func | std::function< void()> | Callback invoked on every idle iteration. |
~Idler
virtual
virtual ~Idler() = defaultDefined in src/base/include/icy/idler.h:120
Defaulted destructor.
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 > _handleType: uv::Handle< uv_idle_t >
Defined 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.
