RADLib
RADical C++ application framework
RADCore::EventLoop Class Reference

RADCore task event loop with locked and low-latency scheduling strategies. More...

#include <RADCore.h>

Public Types

using Task = std::function< void()>
 Task callable type. More...
 

Public Member Functions

 EventLoop (LoopStrategy strategy=RADEVENT_LOCK)
 Creates an event loop using strategy. More...
 
 ~EventLoop ()
 Stops and destroys the loop implementation. More...
 
void post (Priority priority, Task task)
 Posts task with explicit priority. More...
 
void post (Task task)
 Posts task at normal priority. More...
 
bool processEvents ()
 Processes currently queued events without entering the main loop. More...
 
void exec ()
 Runs the event loop until quit() is called. More...
 
void quit ()
 Requests the event loop to exit. More...
 
bool isEventThread () const
 Returns true when called from the thread running exec(). More...
 
EventLoopHandle handle () const
 Returns a weak posting handle safe to keep beyond this EventLoop object. More...
 
bool postDelayed (int delayMs, Task task)
 Posts task to this loop after delayMs milliseconds; returns false when stopped. More...
 
template<typename F , typename... Args>
void post (Priority priority, F &&f, Args &&... args)
 Binds f and args into a task posted with priority. More...
 
template<typename F , typename... Args>
void post (F &&f, Args &&... args)
 Binds f and args into a normal-priority task. More...
 

Friends

class EventLoopHandle
 

Detailed Description

RADCore task event loop with locked and low-latency scheduling strategies.

Member Typedef Documentation

◆ Task

using RADCore::EventLoop::Task = std::function<void()>

Task callable type.

Constructor & Destructor Documentation

◆ EventLoop()

RADCore::EventLoop::EventLoop ( LoopStrategy  strategy = RADEVENT_LOCK)

Creates an event loop using strategy.

◆ ~EventLoop()

RADCore::EventLoop::~EventLoop ( )

Stops and destroys the loop implementation.

Member Function Documentation

◆ exec()

void RADCore::EventLoop::exec ( )

Runs the event loop until quit() is called.

◆ handle()

EventLoopHandle RADCore::EventLoop::handle ( ) const

Returns a weak posting handle safe to keep beyond this EventLoop object.

◆ isEventThread()

bool RADCore::EventLoop::isEventThread ( ) const

Returns true when called from the thread running exec().

◆ post() [1/4]

template<typename F , typename... Args>
void RADCore::EventLoop::post ( F &&  f,
Args &&...  args 
)
inline

Binds f and args into a normal-priority task.

◆ post() [2/4]

template<typename F , typename... Args>
void RADCore::EventLoop::post ( Priority  priority,
F &&  f,
Args &&...  args 
)
inline

Binds f and args into a task posted with priority.

◆ post() [3/4]

void RADCore::EventLoop::post ( Priority  priority,
Task  task 
)

Posts task with explicit priority.

◆ post() [4/4]

void RADCore::EventLoop::post ( Task  task)

Posts task at normal priority.

◆ postDelayed()

bool RADCore::EventLoop::postDelayed ( int  delayMs,
Task  task 
)

Posts task to this loop after delayMs milliseconds; returns false when stopped.

◆ processEvents()

bool RADCore::EventLoop::processEvents ( )

Processes currently queued events without entering the main loop.

◆ quit()

void RADCore::EventLoop::quit ( )

Requests the event loop to exit.

Friends And Related Function Documentation

◆ EventLoopHandle

friend class EventLoopHandle
friend

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