aboutsummaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorGravatar Nicolas Noble <nnoble@google.com>2015-04-03 13:32:47 -0700
committerGravatar Nicolas "Pixel" Noble <pixel@nobis-crew.org>2015-04-03 23:02:47 +0200
commit91647cc8154b06df9225eaa67b03b05fbb353043 (patch)
tree7a8e86cfd6f2c983aaa276f440061b299fe79151 /test
parent300ebc4c623b46f45506ac14b31e2660196dc596 (diff)
Adding joinable threads, and gpr_thd_join.
Diffstat (limited to 'test')
-rw-r--r--test/core/support/thd_test.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/test/core/support/thd_test.c b/test/core/support/thd_test.c
index c03a905d2a..bb3d54a262 100644
--- a/test/core/support/thd_test.c
+++ b/test/core/support/thd_test.c
@@ -60,12 +60,16 @@ static void thd_body(void *v) {
gpr_mu_unlock(&t->mu);
}
+static void thd_body_joinable(void *v) { }
+
/* Test that we can create a number of threads and wait for them. */
static void test(void) {
int i;
gpr_thd_id thd;
+ gpr_thd_id thds[1000];
struct test t;
int n = 1000;
+ gpr_thd_options options = gpr_thd_options_default();
gpr_mu_init(&t.mu);
gpr_cv_init(&t.done_cv);
t.n = n;
@@ -79,6 +83,13 @@ static void test(void) {
}
gpr_mu_unlock(&t.mu);
GPR_ASSERT(t.n == 0);
+ gpr_thd_options_set_joinable(&options);
+ for (i = 0; i < n; i++) {
+ GPR_ASSERT(gpr_thd_new(&thds[i], &thd_body_joinable, NULL, &options));
+ }
+ for (i = 0; i < n; i++) {
+ gpr_thd_join(thds[i]);
+ }
}
/* ------------------------------------------------- */