Seastar
High performance C++ framework for concurrent servers
Public Member Functions | Static Public Member Functions | List of all members
seastar::thread Class Reference

Detailed Description

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 <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 bool running_in_thread ()
 

Constructor & Destructor Documentation

◆ ~thread()

seastar::thread::~thread ( )
inline

Destroys a thread object.

The thread must not represent a running thread of execution (see join()).

Member Function Documentation

◆ should_yield()

static bool seastar::thread::should_yield ( )
static

Checks whether this thread ought to call yield() now.

Useful where we cannot call yield() immediately because we Need to take some cleanup action first.

◆ yield()

static void seastar::thread::yield ( )
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.


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