34 #ifndef GRPCXX_IMPL_THD_NO_CXX11_H
35 #define GRPCXX_IMPL_THD_NO_CXX11_H
37 #include <grpc/support/thd.h>
45 func_ =
new thread_function<T>(fptr, obj);
50 if (!joined_) std::terminate();
60 gpr_thd_options options = gpr_thd_options_default();
61 gpr_thd_options_set_joinable(&options);
62 gpr_thd_new(&thd_, thread_func, (
void *)func_, &options);
64 static void thread_func(
void *arg) {
65 thread_function_base *func = (thread_function_base *)arg;
68 class thread_function_base {
70 virtual ~thread_function_base() {}
71 virtual void call() = 0;
74 class thread_function :
public thread_function_base {
76 thread_function(
void (T::*fptr)(), T *obj) : fptr_(fptr), obj_(obj) {}
77 virtual void call() { (obj_->*fptr_)(); }
83 thread_function_base *func_;
89 void operator=(
const thread &);
94 #endif // GRPCXX_IMPL_THD_NO_CXX11_H
thread(void(T::*fptr)(), T *obj)
Definition: thd_no_cxx11.h:44
void join()
Definition: thd_no_cxx11.h:53
Definition: thd_no_cxx11.h:41
~thread()
Definition: thd_no_cxx11.h:49