LeechCraft  0.6.70-3565-g2d86529
Modular cross-platform feature rich live environment.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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)
 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 69 of file delayedexecutor.h.

Member Typedef Documentation

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

Definition at line 73 of file delayedexecutor.h.

Constructor & Destructor Documentation

LeechCraft::Util::DelayedExecutor::DelayedExecutor ( Actor_f  action,
int  timeout = 0 
)

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.

Parameters
[in]actionThe action to execute.
[in]timeoutThe timeout before executing the action.

Definition at line 37 of file delayedexecutor.cpp.


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