diff options
author | Vijay Pai <vpai@google.com> | 2018-02-13 14:40:39 -0800 |
---|---|---|
committer | Vijay Pai <vpai@google.com> | 2018-02-15 21:30:13 -0800 |
commit | 58a62755fc6546a117b7b8f3a0a344f85b2ea5f9 (patch) | |
tree | 294e8432672a2a8b3b2bd1bab7d24e75e1a6d4b6 /test/core/gpr/cpu_test.cc | |
parent | b0d71823a0f031ad1c04be30f22653177139da0b (diff) |
Remove support for detached threads. All threads must be joined.
Diffstat (limited to 'test/core/gpr/cpu_test.cc')
-rw-r--r-- | test/core/gpr/cpu_test.cc | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/test/core/gpr/cpu_test.cc b/test/core/gpr/cpu_test.cc index 9f2c3f1923..c97facef7d 100644 --- a/test/core/gpr/cpu_test.cc +++ b/test/core/gpr/cpu_test.cc @@ -101,7 +101,7 @@ static void cpu_test(void) { uint32_t i; int cores_seen = 0; struct cpu_test ct; - gpr_thd_id thd; + gpr_thd_id* thd; ct.ncores = gpr_cpu_num_cores(); GPR_ASSERT(ct.ncores > 0); ct.nthreads = static_cast<int>(ct.ncores) * 3; @@ -110,15 +110,22 @@ static void cpu_test(void) { gpr_mu_init(&ct.mu); gpr_cv_init(&ct.done_cv); ct.is_done = 0; - for (i = 0; i < ct.ncores * 3; i++) { - GPR_ASSERT( - gpr_thd_new(&thd, "grpc_cpu_test", &worker_thread, &ct, nullptr)); + + uint32_t nthreads = ct.ncores * 3; + thd = static_cast<gpr_thd_id*>(gpr_malloc(sizeof(thd[0]) * nthreads)); + + for (i = 0; i < nthreads; i++) { + GPR_ASSERT(gpr_thd_new(&thd[i], "grpc_cpu_test", &worker_thread, &ct)); } gpr_mu_lock(&ct.mu); while (!ct.is_done) { gpr_cv_wait(&ct.done_cv, &ct.mu, gpr_inf_future(GPR_CLOCK_MONOTONIC)); } gpr_mu_unlock(&ct.mu); + for (i = 0; i < nthreads; i++) { + gpr_thd_join(thd[i]); + } + gpr_free(thd); fprintf(stderr, "Saw cores ["); fflush(stderr); for (i = 0; i < ct.ncores; i++) { |