libcoro  1.0
Coroutine support library for C++20
Classes | Public Types | Public Member Functions | Static Public Member Functions | List of all members
coro::scheduler_t< CondVar > Class Template Reference

scheduler for coroutines More...

#include <scheduler.h>

+ Collaboration diagram for coro::scheduler_t< CondVar >:

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_tcurrent ()
 returns current scheduler (for the current thread) More...
 

Detailed Description

template<typename CondVar>
class coro::scheduler_t< CondVar >

scheduler for coroutines

Implements co_awaitable sleep_for and sleep_until

Template Parameters
CondVarcustom condition variable implementation - compatible API with std::condition_variable

Definition at line 21 of file scheduler.h.


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