19 #ifndef GRPC_CORE_LIB_GPRPP_THD_H
20 #define GRPC_CORE_LIB_GPRPP_THD_H
50 Options() : joinable_(true), tracked_(true), stack_size_(0) {}
81 Thread() : state_(FAKE), impl_(nullptr) {}
89 Thread(
const char* thd_name,
void (*thd_body)(
void* arg),
void* arg,
95 : state_(other.state_), impl_(other.impl_), options_(other.options_) {
97 other.impl_ =
nullptr;
105 if (
this != &other) {
111 state_ = other.state_;
113 options_ = other.options_;
114 other.state_ = MOVED;
115 other.impl_ =
nullptr;
129 if (impl_ !=
nullptr) {
145 if (impl_ !=
nullptr) {
166 enum ThreadState { FAKE, ALIVE, STARTED, DONE, FAILED, MOVED };
168 internal::ThreadInternalsInterface* impl_;
bool tracked() const
Definition: thd.h:63
size_t stack_size() const
Definition: thd.h:71
Options & set_joinable(bool joinable)
Set whether the thread is joinable or detached.
Definition: thd.h:52
Options & set_stack_size(size_t bytes)
Sets thread stack size (in bytes).
Definition: thd.h:67
bool joinable() const
Definition: thd.h:56
Options & set_tracked(bool tracked)
Set whether the thread is tracked for fork support.
Definition: thd.h:59
Options()
Definition: thd.h:50
void Join()
Definition: thd.h:144
void Start()
Definition: thd.h:128
Thread(const char *thd_name, void(*thd_body)(void *arg), void *arg, bool *success=nullptr, const Options &options=Options())
Normal constructor to create a thread with name thd_name, which will execute a thread based on functi...
Thread & operator=(Thread &&other) noexcept
Move assignment operator for thread.
Definition: thd.h:104
~Thread()
The destructor is strictly optional; either the thread never came to life and the constructor itself ...
Definition: thd.h:126
Thread(Thread &&other) noexcept
Move constructor for thread.
Definition: thd.h:94
Thread()
Default constructor only to allow use in structs that lack constructors Does not produce a validly-co...
Definition: thd.h:81
Base class for platform-specific thread-state.
Definition: thd.h:37
virtual ~ThreadInternalsInterface()
Definition: thd.h:39
#define GPR_ASSERT(x)
abort() the process if x is zero, having written a line to the log.
Definition: log.h:92
Round Robin Policy.
Definition: backend_metric.cc:26
Definition: executor.h:30