#include "loop.hh"
Classes | |
struct | QuickPfdArray |
Public Types | |
typedef std::function< bool(void)> | BoolSlot |
typedef std::function< bool(PollFD &)> | BPfdSlot |
typedef std::function< bool(const LoopState &)> | DispatcherSlot |
typedef std::function< bool(int8)> | USignalSlot |
typedef std::function< void(void)> | VoidSlot |
typedef std::function< void(PollFD &)> | VPfdSlot |
Public Member Functions | |
uint | add (EventSourceP loop_source, int priority=PRIORITY_NORMAL) |
bool | clear_source (uint *id_pointer) |
void | destroy_loop (void) |
template<class BoolVoidFunctor > | |
uint | exec_callback (BoolVoidFunctor &&bvf, int priority=PRIORITY_NORMAL) |
uint | exec_dispatcher (const DispatcherSlot &sl, int priority=PRIORITY_NORMAL) |
template<class BoolVoidFunctor > | |
uint | exec_idle (BoolVoidFunctor &&bvf) |
template<class BoolVoidPollFunctor > | |
uint | exec_io_handler (BoolVoidPollFunctor &&bvf, int fd, const String &mode, int priority=PRIORITY_NORMAL) |
template<class BoolVoidFunctor > | |
uint | exec_now (BoolVoidFunctor &&bvf) |
bool | exec_once (uint delay_ms, uint *once_id, const VoidSlot &vfunc, int priority=PRIORITY_NORMAL) |
template<class BoolVoidFunctor > | |
uint | exec_timer (BoolVoidFunctor &&bvf, uint delay_ms, int64 repeat_ms=-1, int priority=PRIORITY_NORMAL) |
uint | exec_usignal (int8 signum, const USignalSlot &sl, int priority=PRIORITY_NOW -1) |
bool | flag_primary (bool on) |
bool | has_primary (void) |
MainLoop * | main_loop () const |
void | remove (uint id) |
bool | try_remove (uint id) |
void | wakeup () |
Static Public Attributes | |
static const int16 | PRIORITY_ASCENT |
static const int16 | PRIORITY_CEILING |
static const int16 | PRIORITY_HIGH |
static const int16 | PRIORITY_IDLE |
static const int16 | PRIORITY_LOW |
static const int16 | PRIORITY_NEXT |
static const int16 | PRIORITY_NORMAL |
static const int16 | PRIORITY_NOW |
static const int16 | PRIORITY_UPDATE |
Protected Types | |
typedef std::vector< EventSourceP > | SourceList |
Protected Member Functions | |
bool | check_sources_Lm (LoopState &, const QuickPfdArray &) |
void | collect_sources_Lm (LoopState &) |
void | dispatch_source_Lm (LoopState &) |
EventLoop (MainLoop &) | |
EventSourceP & | find_first_L () |
EventSourceP & | find_source_L (uint id) |
bool | has_primary_L (void) |
void | kill_sources_Lm (void) |
bool | prepare_sources_Lm (LoopState &, QuickPfdArray &) |
void | remove_source_Lm (EventSourceP source) |
void | unpoll_sources_U () |
virtual | ~EventLoop () |
Protected Attributes | |
int16 | dispatch_priority_ |
MainLoop * | main_loop_ |
std::vector< EventSourceP > | poll_sources_ |
bool | primary_ |
SourceList | sources_ |
Loop object, polling for events and executing callbacks in accordance.
|
protected |
typedef std::function<void (void)> VoidSlot |
typedef std::function<bool (void)> BoolSlot |
typedef std::function<bool (const LoopState&)> DispatcherSlot |
typedef std::function<bool (int8)> USignalSlot |
|
protectedvirtual |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
void wakeup | ( | ) |
Wakeup loop from polling.
uint add | ( | EventSourceP | loop_source, |
int | priority = PRIORITY_NORMAL |
||
) |
Adds a new source to the loop with custom priority.
void remove | ( | uint | id | ) |
Removes a source from loop, the source must be present.
bool try_remove | ( | uint | id | ) |
Tries to remove a source, returns if successfull.
bool clear_source | ( | uint * | id_pointer | ) |
Remove source if `id_pointer` and `*id_pointer` are valid.
void destroy_loop | ( | void | ) |
Remove all sources from a loop and prevent any further execution. The destroy_loop() method removes all sources from a loop and in case of a sub EventLoop (see create_sub_loop()) removes it from its associated main loop. Calling destroy_loop() on a main loop also calls destroy_loop() for all its sub loops. Note that MainLoop objects are artificially kept alive until MainLoop::destroy_loop() is called, so calling destroy_loop() is mandatory for MainLoop objects to prevent object leaks. This method must be called only once on a loop.
bool has_primary | ( | void | ) |
Indicates whether loop contains primary sources.
bool flag_primary | ( | bool | on | ) |
MainLoop * main_loop | ( | ) | const |
Get the main loop for this loop.
uint exec_now | ( | BoolVoidFunctor && | bvf | ) |
Execute a callback as primary source with priority "now" (highest), returning true repeats callback.
uint exec_callback | ( | BoolVoidFunctor && | bvf, |
int | priority = PRIORITY_NORMAL |
||
) |
Execute a callback at user defined priority returning true repeats callback.
uint exec_idle | ( | BoolVoidFunctor && | bvf | ) |
Execute a callback with priority "idle", returning true repeats callback.
uint exec_dispatcher | ( | const DispatcherSlot & | sl, |
int | priority = PRIORITY_NORMAL |
||
) |
uint exec_usignal | ( | int8 | signum, |
const USignalSlot & | sl, | ||
int | priority = PRIORITY_NOW -1 |
||
) |
Execute a single dispatcher callback for prepare, check, dispatch.
bool exec_once | ( | uint | delay_ms, |
uint * | once_id, | ||
const VoidSlot & | vfunc, | ||
int | priority = PRIORITY_NORMAL |
||
) |
Execute a signal callback for prepare, check, dispatch.
Execute a callback once, re-schedules the callback if `0 != *once_id`.
uint exec_timer | ( | BoolVoidFunctor && | bvf, |
uint | delay_ms, | ||
int64 | repeat_ms = -1 , |
||
int | priority = PRIORITY_NORMAL |
||
) |
Execute a callback after a specified timeout with adjustable initial timeout, returning true repeats callback.
uint exec_io_handler | ( | BoolVoidPollFunctor && | bvf, |
int | fd, | ||
const String & | mode, | ||
int | priority = PRIORITY_NORMAL |
||
) |
Execute a callback after polling for mode on fd, returning true repeats callback.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
static |
Internal upper limit, don't use.
|
static |
Most important, used for immediate async execution.
|
static |
Threshold for priorization across different loops.
|
static |
Very important, used for timers or IO handlers.
|
static |
Important, used for async operations and callbacks.
|
static |
Normal importantance, GUI event processing, RPC.
|
static |
Mildly important, used for GUI updates or user information.
|
static |
Mildly important, used for background tasks.
|
static |
Unimportant, used when everything else done.