Async++ unknown
Async (co_await/co_return) code for C++
Loading...
Searching...
No Matches
asyncpp::dispatcher Class Referenceabstract

Basic dispatcher interface class. More...

#include <asyncpp/dispatcher.h>

Inheritance diagram for asyncpp::dispatcher:
[legend]

Public Member Functions

virtual void push (std::function< void()> cbfn)=0
 

Static Public Member Functions

static dispatchercurrent () noexcept
 

Static Protected Member Functions

static dispatchercurrent (dispatcher *disp)
 Set the current dispatcher for this thread and reurns the current one. Implementers of dispatchers can use this to give convenient access to the current dispatcher, for example for yielding. A dispatcher usually calls this function once at the start of an event loop, before calling any callbacks and persists the return value. It then calls it again after calling all callbacks and restores the previously persisted value. This allows invoking a dispatcher loop from within another dispatcher. The end call is optional if the implementation can guarantee that the thread will terminate afterwards.
 

Detailed Description

Basic dispatcher interface class.

Member Function Documentation

◆ current() [1/2]

static dispatcher * asyncpp::dispatcher::current ( )
inlinestaticnoexcept

Get the dispatcher associated with the current thread. This can be used to shedule more tasks on the current dispatcher. Returns the current dispatcher, or nullptr if the current thread is not associated with a dispatcher.

◆ current() [2/2]

static dispatcher * asyncpp::dispatcher::current ( dispatcher * disp)
inlinestaticprotected

Set the current dispatcher for this thread and reurns the current one. Implementers of dispatchers can use this to give convenient access to the current dispatcher, for example for yielding. A dispatcher usually calls this function once at the start of an event loop, before calling any callbacks and persists the return value. It then calls it again after calling all callbacks and restores the previously persisted value. This allows invoking a dispatcher loop from within another dispatcher. The end call is optional if the implementation can guarantee that the thread will terminate afterwards.

Parameters
dThe dispatcher instance of this thread.
Returns
The previous dispatcher

◆ push()

virtual void asyncpp::dispatcher::push ( std::function< void()> cbfn)
pure virtual

Push a function to be executed on the dispatcher.

The function gets added to the queue and is executed once all existing tasks have run.

Parameters
fnCallback

Implemented in asyncpp::simple_dispatcher, asyncpp::thread_pool, and asyncpp::timer.


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