aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--BUILD32
-rw-r--r--src/core/lib/gprpp/thd_posix.cc2
-rw-r--r--src/core/lib/gprpp/thd_windows.cc35
-rw-r--r--test/core/gprpp/BUILD21
4 files changed, 40 insertions, 50 deletions
diff --git a/BUILD b/BUILD
index 62f99f6426..4fe3dc660e 100644
--- a/BUILD
+++ b/BUILD
@@ -527,8 +527,6 @@ grpc_cc_library(
"src/core/lib/gpr/sync.cc",
"src/core/lib/gpr/sync_posix.cc",
"src/core/lib/gpr/sync_windows.cc",
- "src/core/lib/gprpp/thd_posix.cc",
- "src/core/lib/gprpp/thd_windows.cc",
"src/core/lib/gpr/time.cc",
"src/core/lib/gpr/time_posix.cc",
"src/core/lib/gpr/time_precise.cc",
@@ -538,6 +536,8 @@ grpc_cc_library(
"src/core/lib/gpr/tmpfile_posix.cc",
"src/core/lib/gpr/tmpfile_windows.cc",
"src/core/lib/gpr/wrap_memcpy.cc",
+ "src/core/lib/gprpp/thd_posix.cc",
+ "src/core/lib/gprpp/thd_windows.cc",
"src/core/lib/profiling/basic_timers.cc",
"src/core/lib/profiling/stap_timers.cc",
],
@@ -551,7 +551,6 @@ grpc_cc_library(
"src/core/lib/gpr/spinlock.h",
"src/core/lib/gpr/string.h",
"src/core/lib/gpr/string_windows.h",
- "src/core/lib/gprpp/thd.h",
"src/core/lib/gpr/time_precise.h",
"src/core/lib/gpr/tls.h",
"src/core/lib/gpr/tls_gcc.h",
@@ -559,6 +558,10 @@ grpc_cc_library(
"src/core/lib/gpr/tls_pthread.h",
"src/core/lib/gpr/tmpfile.h",
"src/core/lib/gpr/useful.h",
+ "src/core/lib/gprpp/abstract.h",
+ "src/core/lib/gprpp/manual_constructor.h",
+ "src/core/lib/gprpp/memory.h",
+ "src/core/lib/gprpp/thd.h",
"src/core/lib/profiling/timers.h",
],
language = "c++",
@@ -601,16 +604,6 @@ grpc_cc_library(
)
grpc_cc_library(
- name = "gpr++_base",
- language = "c++",
- public_hdrs = [
- "src/core/lib/gprpp/abstract.h",
- "src/core/lib/gprpp/manual_constructor.h",
- "src/core/lib/gprpp/memory.h",
- ],
-)
-
-grpc_cc_library(
name = "atomic",
hdrs = [
"src/core/lib/gprpp/atomic_with_atm.h",
@@ -632,7 +625,7 @@ grpc_cc_library(
"src/core/lib/gprpp/inlined_vector.h",
],
deps = [
- "gpr++_base",
+ "gpr_base",
],
)
@@ -648,7 +641,7 @@ grpc_cc_library(
public_hdrs = ["src/core/lib/gprpp/orphanable.h"],
deps = [
"debug_location",
- "gpr++_base",
+ "gpr_base",
"grpc_trace",
"ref_counted_ptr",
],
@@ -660,7 +653,7 @@ grpc_cc_library(
public_hdrs = ["src/core/lib/gprpp/ref_counted.h"],
deps = [
"debug_location",
- "gpr++_base",
+ "gpr_base",
"grpc_trace",
"ref_counted_ptr",
],
@@ -671,7 +664,7 @@ grpc_cc_library(
language = "c++",
public_hdrs = ["src/core/lib/gprpp/ref_counted_ptr.h"],
deps = [
- "gpr++_base",
+ "gpr_base",
],
)
@@ -942,13 +935,12 @@ grpc_cc_library(
language = "c++",
public_hdrs = GRPC_PUBLIC_HDRS,
deps = [
- "gpr++_base",
"gpr_base",
"grpc_codegen",
"grpc_trace",
+ "inlined_vector",
"ref_counted",
"ref_counted_ptr",
- "inlined_vector",
],
)
@@ -1424,7 +1416,7 @@ grpc_cc_library(
],
language = "c++",
deps = [
- "gpr++_base",
+ "gpr_base",
"grpc_base",
"grpc_http_filters",
"grpc_transport_chttp2_alpn",
diff --git a/src/core/lib/gprpp/thd_posix.cc b/src/core/lib/gprpp/thd_posix.cc
index 28e47f1aa9..2f6c2edcae 100644
--- a/src/core/lib/gprpp/thd_posix.cc
+++ b/src/core/lib/gprpp/thd_posix.cc
@@ -165,7 +165,7 @@ class ThreadInternalsPosix
Thread::Thread(const char* thd_name, void (*thd_body)(void* arg), void* arg,
bool* success) {
- bool outcome;
+ bool outcome = false;
impl_ =
grpc_core::New<ThreadInternalsPosix>(thd_name, thd_body, arg, &outcome);
if (outcome) {
diff --git a/src/core/lib/gprpp/thd_windows.cc b/src/core/lib/gprpp/thd_windows.cc
index e13c2f63d1..59ea02f3d2 100644
--- a/src/core/lib/gprpp/thd_windows.cc
+++ b/src/core/lib/gprpp/thd_windows.cc
@@ -52,28 +52,22 @@ struct thd_info {
thread_local struct thd_info* g_thd_info;
-/* Destroys a thread info */
-void destroy_thread(struct thd_info* t) {
- CloseHandle(t->join_event);
- gpr_free(t);
-}
-
class ThreadInternalsWindows
: public grpc_core::internal::ThreadInternalsInterface {
public:
- ThreadInternalsWindows(void (*thd_body)(void* arg), void* arg,
- bool* success) {
+ ThreadInternalsWindows(void (*thd_body)(void* arg), void* arg, bool* success)
+ : started_(false) {
gpr_mu_init(&mu_);
gpr_cv_init(&ready_);
HANDLE handle;
info_ = (struct thd_info*)gpr_malloc(sizeof(*info_));
- info->thread = this;
- info->body = thd_body;
- info->arg = arg;
+ info_->thread = this;
+ info_->body = thd_body;
+ info_->arg = arg;
- info->join_event = CreateEvent(nullptr, FALSE, FALSE, nullptr);
- if (info->join_event == nullptr) {
+ info_->join_event = CreateEvent(nullptr, FALSE, FALSE, nullptr);
+ if (info_->join_event == nullptr) {
gpr_free(info_);
*success = false;
} else {
@@ -92,10 +86,10 @@ class ThreadInternalsWindows
GPR_ASSERT(ret);
return 0;
},
- info, 0, nullptr);
+ info_, 0, nullptr);
if (handle == nullptr) {
- destroy_thread(info_);
- *success_ = false;
+ destroy_thread();
+ *success = false;
} else {
CloseHandle(handle);
*success = true;
@@ -118,10 +112,15 @@ class ThreadInternalsWindows
void Join() override {
DWORD ret = WaitForSingleObject(info_->join_event, INFINITE);
GPR_ASSERT(ret == WAIT_OBJECT_0);
- destroy_thread(info_);
+ destroy_thread();
}
private:
+ void destroy_thread() {
+ CloseHandle(info_->join_event);
+ gpr_free(info_);
+ }
+
gpr_mu mu_;
gpr_cv ready_;
bool started_;
@@ -141,7 +140,7 @@ bool Thread::AwaitAll(gpr_timespec deadline) {
Thread::Thread(const char* thd_name, void (*thd_body)(void* arg), void* arg,
bool* success) {
- bool outcome;
+ bool outcome = false;
impl_ = grpc_core::New<ThreadInternalsWindows>(thd_body, arg, &outcome);
if (outcome) {
state_ = ALIVE;
diff --git a/test/core/gprpp/BUILD b/test/core/gprpp/BUILD
index 9eff49e6c0..a8a5739552 100644
--- a/test/core/gprpp/BUILD
+++ b/test/core/gprpp/BUILD
@@ -24,7 +24,6 @@ grpc_cc_test(
language = "C++",
deps = [
"//:gpr",
- "//:gpr++_base",
"//test/core/util:gpr_test_util",
],
)
@@ -37,7 +36,7 @@ grpc_cc_test(
],
language = "C++",
deps = [
- "//:gpr++_base",
+ "//:gpr_base",
"//test/core/util:gpr_test_util",
],
)
@@ -58,41 +57,41 @@ grpc_cc_test(
grpc_cc_test(
name = "orphanable_test",
srcs = ["orphanable_test.cc"],
+ external_deps = [
+ "gtest",
+ ],
language = "C++",
deps = [
"//:orphanable",
"//test/core/util:gpr_test_util",
],
- external_deps = [
- "gtest",
- ],
)
grpc_cc_test(
name = "ref_counted_test",
srcs = ["ref_counted_test.cc"],
+ external_deps = [
+ "gtest",
+ ],
language = "C++",
deps = [
"//:ref_counted",
"//test/core/util:gpr_test_util",
],
- external_deps = [
- "gtest",
- ],
)
grpc_cc_test(
name = "ref_counted_ptr_test",
srcs = ["ref_counted_ptr_test.cc"],
+ external_deps = [
+ "gtest",
+ ],
language = "C++",
deps = [
"//:ref_counted",
"//:ref_counted_ptr",
"//test/core/util:gpr_test_util",
],
- external_deps = [
- "gtest",
- ],
)
grpc_cc_test(