class
MainLoopAn EventLoop implementation that offers public API for running the loop.
Base classes
- class EventLoop
- Loop object, polling for events and executing callbacks in accordance.
Public static variables
- static const int16 PRIORITY_ASCENT
- Threshold for priorization across different loops.
- static const int16 PRIORITY_CEILING
- Internal upper limit, don't use.
- static const int16 PRIORITY_HIGH
- Very important, used for timers or IO handlers.
- static const int16 PRIORITY_IDLE
- Mildly important, used for background tasks.
- static const int16 PRIORITY_LOW
- Unimportant, used when everything else done.
- static const int16 PRIORITY_NEXT
- Important, used for async operations and callbacks.
- static const int16 PRIORITY_NORMAL
- Normal importantance, GUI event processing, RPC.
- static const int16 PRIORITY_NOW
- Most important, used for immediate async execution.
- static const int16 PRIORITY_UPDATE
- Mildly important, used for GUI updates or user information.
Public static functions
Public functions
-
auto add(EventSourceP loop_source,
int priority = PRIORITY_
NORMAL) → uint - Adds a new source to the loop with custom priority.
- auto clear_source(uint* id_pointer) → bool
- Remove source if
id_pointer
and*id_pointer
are valid. - auto create_sub_loop() → EventLoopP
- Creates a new event loop that is run as part of this main loop.
- void destroy_loop(void)
-
template <class BoolVoidFunctor>auto exec_callback(BoolVoidFunctor&& bvf, int priority = PRIORITY_
NORMAL) → uint - Execute a callback at user defined priority returning true repeats callback.
-
template <class BoolVoidFunctor>auto exec_idle(BoolVoidFunctor&& bvf) → uint
- Execute a callback with priority "idle", returning true repeats callback.
-
template <class BoolVoidPollFunctor>auto exec_io_handler(BoolVoidPollFunctor&& bvf, int fd, const String& mode, int priority = PRIORITY_
NORMAL) → uint - Execute a callback after polling for mode on fd, returning true repeats callback.
-
template <class BoolVoidFunctor>auto exec_now(BoolVoidFunctor&& bvf) → uint
- Execute a callback as primary source with priority "now" (highest), returning true repeats callback.
-
auto exec_once(uint delay_ms,
uint* once_id,
const VoidSlot& vfunc,
int priority = PRIORITY_
NORMAL) → bool - Execute a signal callback for prepare, check, dispatch.
-
template <class BoolVoidFunctor>auto exec_timer(BoolVoidFunctor&& bvf, uint delay_ms, int64 repeat_ms = -1, int priority = PRIORITY_
NORMAL) → uint - Execute a callback after a specified timeout with adjustable initial timeout, returning true repeats callback.
-
auto exec_usignal(int8 signum,
const USignalSlot& sl,
int priority = PRIORITY_
NOW -1) → uint - Execute a single dispatcher callback for prepare, check, dispatch.
- auto finishable() → bool
- Indicates wether this loop has no primary sources left to process.
- auto has_primary(void) → bool
- Indicates whether loop contains primary sources.
- auto iterate(bool block) → bool
- Perform one loop iteration and return whether more iterations are needed.
- void iterate_pending()
- Call iterate() until no immediate dispatching is needed.
- auto main_loop() const → MainLoop*
- Get the main loop for this loop.
-
auto mutex() → std::
mutex& - Provide access to the mutex associated with this main loop.
- auto pending() → bool
- Check if iterate() needs to be called for dispatching.
- void quit(int quit_code = 0)
- Cause run() to return with quit_code.
- void remove(uint id)
- Removes a source from loop, the source must be present.
- auto run() → int
- Run loop iterations until a call to quit() or finishable becomes true.
- auto running() → bool
- Indicates if quit() has been called already.
- auto set_g_main_context(GlibGMainContext* glib_main_context) → bool
- Set context to integrate with a GLib GMainContext loop.
- auto try_remove(uint id) → bool
- Tries to remove a source, returns if successfull.
- void wakeup()
- Wakeup loop from polling.
Function documentation
static MainLoopP Ase:: MainLoop:: create()
Create a MainLoop shared pointer handle.
Create a new main loop object, users can run or iterate this loop directly. Note that MainLoop objects have special lifetime semantics that keep them alive until they are explicitely destroyed with destroy_
bool Ase:: MainLoop:: iterate(bool block)
Perform one loop iteration and return whether more iterations are needed.
Returns | Whether more sources need immediate dispatching. |
---|
MainLoop::