![]() |
LeechCraft
0.6.70-13729-g7046a9d2a7
Modular cross-platform feature rich live environment.
|
Executes a given action after a given timeout. More...
#include "delayedexecutor.h"
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... | |
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:
or
Definition at line 67 of file delayedexecutor.h.
typedef std::function<void ()> LC::Util::DelayedExecutor::Actor_f |
Definition at line 71 of file delayedexecutor.h.
LC::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.
[in] | action | The action to execute. |
[in] | timeout | The timeout before executing the action. |
[in] | parent | The parent object of this delayed executor. |
Definition at line 37 of file delayedexecutor.cpp.