diff options
author | Vijay Pai <vpai@google.com> | 2018-03-01 11:36:47 -0800 |
---|---|---|
committer | Vijay Pai <vpai@google.com> | 2018-03-01 11:47:36 -0800 |
commit | 2fe87b09055cd256cdce038c4c70d92b955c991b (patch) | |
tree | a7652e9285797130e4d4ece7a6f271530be4b14f /test/core/gpr | |
parent | 8ffa1ae93310646cdf1b15c3a8c2655268d1a47f (diff) |
Move assignment for Thread, make destructor optional, loop cv waits
Diffstat (limited to 'test/core/gpr')
-rw-r--r-- | test/core/gpr/arena_test.cc | 3 | ||||
-rw-r--r-- | test/core/gpr/cpu_test.cc | 4 | ||||
-rw-r--r-- | test/core/gpr/mpscq_test.cc | 8 | ||||
-rw-r--r-- | test/core/gpr/spinlock_test.cc | 4 | ||||
-rw-r--r-- | test/core/gpr/sync_test.cc | 6 | ||||
-rw-r--r-- | test/core/gpr/tls_test.cc | 3 |
6 files changed, 9 insertions, 19 deletions
diff --git a/test/core/gpr/arena_test.cc b/test/core/gpr/arena_test.cc index b00c014cea..111414ea3e 100644 --- a/test/core/gpr/arena_test.cc +++ b/test/core/gpr/arena_test.cc @@ -20,7 +20,6 @@ #include <inttypes.h> #include <string.h> -#include <new> #include <grpc/support/alloc.h> #include <grpc/support/log.h> @@ -102,7 +101,7 @@ static void concurrent_test(void) { grpc_core::Thread thds[CONCURRENT_TEST_THREADS]; for (int i = 0; i < CONCURRENT_TEST_THREADS; i++) { - new (&thds[i]) + thds[i] = grpc_core::Thread("grpc_concurrent_test", concurrent_test_body, &args); thds[i].Start(); } diff --git a/test/core/gpr/cpu_test.cc b/test/core/gpr/cpu_test.cc index 279e6e6f5a..1052d40b42 100644 --- a/test/core/gpr/cpu_test.cc +++ b/test/core/gpr/cpu_test.cc @@ -25,7 +25,6 @@ #include <stdio.h> #include <string.h> -#include <new> #include <grpc/support/alloc.h> #include <grpc/support/log.h> @@ -118,7 +117,7 @@ static void cpu_test(void) { static_cast<grpc_core::Thread*>(gpr_malloc(sizeof(*thd) * nthreads)); for (i = 0; i < nthreads; i++) { - new (&thd[i]) grpc_core::Thread("grpc_cpu_test", &worker_thread, &ct); + thd[i] = grpc_core::Thread("grpc_cpu_test", &worker_thread, &ct); thd[i].Start(); } gpr_mu_lock(&ct.mu); @@ -128,7 +127,6 @@ static void cpu_test(void) { gpr_mu_unlock(&ct.mu); for (i = 0; i < nthreads; i++) { thd[i].Join(); - thd[i].~Thread(); } gpr_free(thd); fprintf(stderr, "Saw cores ["); diff --git a/test/core/gpr/mpscq_test.cc b/test/core/gpr/mpscq_test.cc index 1e929fcf33..8c0873941f 100644 --- a/test/core/gpr/mpscq_test.cc +++ b/test/core/gpr/mpscq_test.cc @@ -19,7 +19,6 @@ #include "src/core/lib/gpr/mpscq.h" #include <stdlib.h> -#include <new> #include <grpc/support/alloc.h> #include <grpc/support/log.h> @@ -85,7 +84,7 @@ static void test_mt(void) { ta[i].ctr = 0; ta[i].q = &q; ta[i].start = &start; - new (&thds[i]) grpc_core::Thread("grpc_mt_test", test_thread, &ta[i]); + thds[i] = grpc_core::Thread("grpc_mt_test", test_thread, &ta[i]); thds[i].Start(); } size_t num_done = 0; @@ -155,7 +154,7 @@ static void test_mt_multipop(void) { ta[i].ctr = 0; ta[i].q = &q; ta[i].start = &start; - new (&thds[i]) grpc_core::Thread("grpc_multipop_test", test_thread, &ta[i]); + thds[i] = grpc_core::Thread("grpc_multipop_test", test_thread, &ta[i]); thds[i].Start(); } pull_args pa; @@ -167,8 +166,7 @@ static void test_mt_multipop(void) { pa.start = &start; gpr_mu_init(&pa.mu); for (size_t i = 0; i < GPR_ARRAY_SIZE(pull_thds); i++) { - new (&pull_thds[i]) - grpc_core::Thread("grpc_multipop_pull", pull_thread, &pa); + pull_thds[i] = grpc_core::Thread("grpc_multipop_pull", pull_thread, &pa); pull_thds[i].Start(); } gpr_event_set(&start, (void*)1); diff --git a/test/core/gpr/spinlock_test.cc b/test/core/gpr/spinlock_test.cc index ac9f70f301..0ee72edb15 100644 --- a/test/core/gpr/spinlock_test.cc +++ b/test/core/gpr/spinlock_test.cc @@ -22,7 +22,6 @@ #include <stdio.h> #include <stdlib.h> -#include <new> #include <grpc/support/alloc.h> #include <grpc/support/log.h> @@ -69,7 +68,7 @@ static void test_destroy(struct test* m) { static void test_create_threads(struct test* m, void (*body)(void* arg)) { int i; for (i = 0; i != m->thread_count; i++) { - new (&m->threads[i]) grpc_core::Thread("grpc_create_threads", body, m); + m->threads[i] = grpc_core::Thread("grpc_create_threads", body, m); m->threads[i].Start(); } } @@ -79,7 +78,6 @@ static void test_wait(struct test* m) { int i; for (i = 0; i != m->thread_count; i++) { m->threads[i].Join(); - m->threads[i].~Thread(); } } diff --git a/test/core/gpr/sync_test.cc b/test/core/gpr/sync_test.cc index 487f394b14..24b4562819 100644 --- a/test/core/gpr/sync_test.cc +++ b/test/core/gpr/sync_test.cc @@ -22,7 +22,6 @@ #include <stdio.h> #include <stdlib.h> -#include <new> #include <grpc/support/alloc.h> #include <grpc/support/log.h> @@ -196,7 +195,7 @@ static void test_destroy(struct test* m) { static void test_create_threads(struct test* m, void (*body)(void* arg)) { int i; for (i = 0; i != m->nthreads; i++) { - new (&m->threads[i]) grpc_core::Thread("grpc_create_threads", body, m); + m->threads[i] = grpc_core::Thread("grpc_create_threads", body, m); m->threads[i].Start(); } } @@ -210,7 +209,6 @@ static void test_wait(struct test* m) { gpr_mu_unlock(&m->mu); for (int i = 0; i != m->nthreads; i++) { m->threads[i].Join(); - m->threads[i].~Thread(); } } @@ -258,7 +256,7 @@ static void test(const char* name, void (*body)(void* m), m = test_new(10, iterations, incr_step); grpc_core::Thread extra_thd; if (extra != nullptr) { - new (&extra_thd) grpc_core::Thread(name, extra, m); + extra_thd = grpc_core::Thread(name, extra, m); extra_thd.Start(); m->done++; /* one more thread to wait for */ } diff --git a/test/core/gpr/tls_test.cc b/test/core/gpr/tls_test.cc index a060cd47f1..0502fc7ef4 100644 --- a/test/core/gpr/tls_test.cc +++ b/test/core/gpr/tls_test.cc @@ -22,7 +22,6 @@ #include <stdio.h> #include <stdlib.h> -#include <new> #include <grpc/support/log.h> #include <grpc/support/sync.h> @@ -56,7 +55,7 @@ int main(int argc, char* argv[]) { gpr_tls_init(&test_var); for (auto& th : threads) { - new (&th) grpc_core::Thread("grpc_tls_test", thd_body, nullptr); + th = grpc_core::Thread("grpc_tls_test", thd_body, nullptr); th.Start(); } for (auto& th : threads) { |