LeechCraft  0.6.70-10870-g558588d6ec
Modular cross-platform feature rich live environment.
LeechCraft::Util::DelayedExecutor Class Reference

Executes a given action after a given timeout. More...

#include "delayedexecutor.h"

+ Inheritance diagram for LeechCraft::Util::DelayedExecutor:
+ Collaboration diagram for LeechCraft::Util::DelayedExecutor:

Public Types

typedef std::function< void()> Actor_f
 

Public Member Functions

 DelayedExecutor (Actor_f action, int timeout=0, QObject *parent=nullptr)
 Constructs the delayed executor. More...
 

Detailed Description

Executes a given action after a given timeout.

This class can be used to schedule execution of arbitrary functions after some arbitrary amount of time.

The DelayedExecutor objects should be created via new on heap, and they will delete themselves after the corresponding action is executed.

The typical usage is as follows:

new Util::DelayedExecutor
{
[]
{
// body of some lambda
},
interval
};

or

new Util::DelayedExecutor
{
someCallable,
interval
};

Definition at line 70 of file delayedexecutor.h.

Member Typedef Documentation

◆ Actor_f

typedef std::function<void ()> LeechCraft::Util::DelayedExecutor::Actor_f

Definition at line 74 of file delayedexecutor.h.

Constructor & Destructor Documentation

◆ DelayedExecutor()

LeechCraft::Util::DelayedExecutor::DelayedExecutor ( Actor_f  action,
int  timeout = 0,
QObject *  parent = nullptr 
)

Constructs the delayed executor.

Schedules the execution of action after a given timeout.

If the timeout is 0, the action will be executed next time event loop is run.

If the parent object is passed and it is destroyed before the delayed executor fires, the action will not be performed. This is useful to avoid execution the action if it depends on some object being alive.

Parameters
[in]actionThe action to execute.
[in]timeoutThe timeout before executing the action.
[in]parentThe parent object of this delayed executor.

Definition at line 37 of file delayedexecutor.cpp.


The documentation for this class was generated from the following files: