libcoro
1.0
Coroutine support library for C++20
|
scheduler for coroutines More...
#include <scheduler.h>
Classes | |
class | pending_cancel |
While this object is held, cancel is in effect. More... | |
Public Types | |
using | resume_cb = function< void(notify_t)> |
A function responsible to resume scheduled coroutine. More... | |
Public Member Functions | |
scheduler_t ()=default | |
initialize the scheduler. It is not started, you must start it manually More... | |
template<std::convertible_to< CondVar > CondVarCfg> | |
scheduler_t (CondVarCfg &&cfg) | |
initialize the scheduler. It is not started, you must start it manually More... | |
~scheduler_t () | |
stop and destroy scheduler More... | |
future< void > | sleep_until (std::chrono::system_clock::time_point tp, ident_t ident=nullptr) |
sleep until specified time point More... | |
template<typename A , typename B > | |
future< void > | sleep_for (std::chrono::duration< A, B > dur, ident_t ident=nullptr) |
sleep for specified duration More... | |
template<typename T , std::invocable< notify_t > ResumeCB> | |
decltype(auto) | run (future< T > &fut, ResumeCB &&cb) |
run the scheduler in signle thread mode, stop when future is ready More... | |
template<typename T , std::invocable< notify_t > ResumeCB> | |
decltype(auto) | run (future< T > &&fut, ResumeCB &&cb) |
run the scheduler in signle thread mode, stop when future is ready More... | |
template<typename T > | |
decltype(auto) | run (future< T > &fut) |
run the scheduler in signle thread mode, stop when future is ready More... | |
template<typename T > | |
decltype(auto) | run (future< T > &&fut) |
run the scheduler in signle thread mode, stop when future is ready More... | |
template<std::invocable< notify_t > ResumeCB> | |
bool | start (ResumeCB &&resumecb) |
Start scheduler at background. More... | |
bool | start () |
Start scheduler at background. More... | |
void | stop () |
stop the running scheduler More... | |
pending_cancel | cancel (ident_t ident) |
Cancel scheduled operation. More... | |
Static Public Member Functions | |
static auto | thread_pool (unsigned int threads) |
Create a thread pool for the scheduler. More... | |
static auto | thread_pool (std::shared_ptr< coro::thread_pool > pool) |
Attach a thread pool to the scheduler. More... | |
static scheduler_t * | current () |
returns current scheduler (for the current thread) More... | |
scheduler for coroutines
Implements co_awaitable sleep_for and sleep_until
CondVar | custom condition variable implementation - compatible API with std::condition_variable |
Definition at line 21 of file scheduler.h.