manages cooperative scheduling of tasks within a single operating system thread. More...
#include <thread.hpp>
Inherits boost::cmt::abstract_thread.
Public Member Functions | |
void | async (const boost::function< void()> &t, priority p=priority()) |
template<typename T > | |
future< T > | async (const boost::function< T()> &t, priority prio=priority(), const char *n="") |
template<typename T > | |
T | sync (const boost::function< T()> &t, priority prio, uint64_t timeout_us=-1, const char *n="") |
template<typename T > | |
T | sync (const boost::function< T()> &t, uint64_t timeout_us=-1, const char *n="") |
void | yield () |
void | usleep (uint64_t us) |
void | quit () |
void | exec () |
priority | current_priority () const |
Static Public Member Functions | |
static thread & | current () |
static thread * | create () |
Protected Member Functions | |
void | wait (const promise_base::ptr &p, uint64_t timeout_us) |
void | notify (const promise_base::ptr &p) |
void | exec_fiber () |
Friends | |
class | promise_base |
manages cooperative scheduling of tasks within a single operating system thread.
void boost::cmt::thread::exec | ( | ) |
If no current context, create a new context running exec() If a current context exists, process tasks until the queue is empty and then block.
void boost::cmt::thread::yield | ( | ) |
Switches from the current task to the next ready task.
If there are no other ready tasks and the input queue is empty then return immediately.
If there are no other ready contexts, but items on the input queue then push this context into the ready queue, mark current as NULL and then start a new context running exec() to process the next item on the input queue. Yield will return next time a context yields.
If there are other ready contexts, push this context on to the end and then yield to the first ready context. Yield will return after all other ready tasks have yielded at least once.