Seastar
High performance C++ framework for concurrent servers
|
thread - stateful thread of execution
Threads allow using seastar APIs in a blocking manner, by calling future::get() on a non-ready future. When this happens, the thread is put to sleep until the future becomes ready.
#include <seastar/core/thread.hh>
Public Member Functions | |
thread ()=default | |
Constructs a thread object that does not represent a thread of execution. | |
template<typename Func > | |
thread (Func func) | |
Constructs a thread object that represents a thread of execution. More... | |
template<typename Func > | |
thread (thread_attributes attr, Func func) | |
Constructs a thread object that represents a thread of execution. More... | |
thread (thread &&x) noexcept=default | |
Moves a thread object. | |
thread & | operator= (thread &&x) noexcept=default |
Move-assigns a thread object. | |
~thread () | |
Destroys a thread object. More... | |
future | join () |
Waits for thread execution to terminate. More... | |
Static Public Member Functions | |
static void | yield () |
Voluntarily defer execution of current thread. More... | |
static bool | should_yield () |
Checks whether this thread ought to call yield() now. More... | |
static void | maybe_yield () |
Yield if this thread ought to call yield() now. More... | |
static bool | running_in_thread () |
|
inline |
Destroys a thread
object.
The thread must not represent a running thread of execution (see join()).
|
static |
Yield if this thread ought to call yield() now.
Useful where a code does long running computation and does not want to hog cpu for more then its share
|
static |
|
static |
Voluntarily defer execution of current thread.
Gives other threads/fibers a chance to run on current CPU. The current thread will resume execution promptly.