Mercury Currency Engine
Classes | Typedefs | Functions
scheduler.hpp File Reference
#include <limits.h>
#include <memory>
#include <condition_variable>
#include <deque>
#include <thread>
#include <exception>
#include <utility>
#include <type_traits>
#include "function_utility.hpp"
#include "atomic.hpp"
#include "coroutine.hpp"
Include dependency graph for scheduler.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  mce::lifecycle
 an interface for implementing lifecycle control operations More...
 
struct  mce::lifecycle::implementation
 virtual interface for implementors of lifecycle More...
 
struct  mce::scheduler
 object responsible for scheduling and executing coroutines More...
 
struct  mce::scheduler::park
 fundamental structure for allowing blocking of coroutines running on a scheduler More...
 
struct  mce::scheduler::park::continuation
 
struct  mce::scheduler::parkable
 object containing information to block and unblock a coroutine (running in a scheduler) or thread More...
 
class  mce::scheduler::parkable::unpark_exception
 
struct  mce::scheduler::parkable_notify
 
struct  mce::scheduler::measurement
 a struct allowing comparison of scheduler workload More...
 

Typedefs

template<typename T >
using mce::detail::queue = std::deque< T >
 

Functions

scheduler *& mce::detail::tl_this_scheduler ()
 
scheduler *& mce::detail::tl_this_scheduler_redirect ()
 
bool mce::in_scheduler ()
 returns true if calling scope is executing inside a running scheduler More...
 
scheduler & mce::this_scheduler ()
 returns a shared pointer to the scheduler the calling scope is running in More...
 

Detailed Description

This header is the heart of this library's code. Much of the code here is unusual and indirect, but necessary, to facilitate the functionality provided by the greater codebase.

Function Documentation

◆ in_scheduler()

bool mce::in_scheduler ( )
inline

returns true if calling scope is executing inside a running scheduler

return true if calling code is running in a scheduler, else false

◆ this_scheduler()

scheduler & mce::this_scheduler ( )
inline

returns a shared pointer to the scheduler the calling scope is running in

acquire a reference to the scheduler running on the current thread

This operation is guaranteed to not fail, but it will return an empty pointer if called from a thread that is not running a scheduler.