Skip to content
Snippets Groups Projects
Commit b19489c6 authored by Sree Kuchibhotla's avatar Sree Kuchibhotla
Browse files

Minor code cleanup

parent cc43d693
No related branches found
No related tags found
No related merge requests found
...@@ -41,6 +41,8 @@ ...@@ -41,6 +41,8 @@
#include <grpc/support/time.h> #include <grpc/support/time.h>
#include "test/core/util/test_config.h" #include "test/core/util/test_config.h"
#define NUM_THREADS 300
struct test { struct test {
gpr_mu mu; gpr_mu mu;
int n; int n;
...@@ -79,15 +81,14 @@ static void test_options(void) { ...@@ -79,15 +81,14 @@ static void test_options(void) {
static void test(void) { static void test(void) {
int i; int i;
gpr_thd_id thd; gpr_thd_id thd;
gpr_thd_id thds[300]; gpr_thd_id thds[NUM_THREADS];
struct test t; struct test t;
int n = 300;
gpr_thd_options options = gpr_thd_options_default(); gpr_thd_options options = gpr_thd_options_default();
gpr_mu_init(&t.mu); gpr_mu_init(&t.mu);
gpr_cv_init(&t.done_cv); gpr_cv_init(&t.done_cv);
t.n = n; t.n = NUM_THREADS;
t.is_done = 0; t.is_done = 0;
for (i = 0; i != n; i++) { for (i = 0; i < NUM_THREADS; i++) {
GPR_ASSERT(gpr_thd_new(&thd, &thd_body, &t, NULL)); GPR_ASSERT(gpr_thd_new(&thd, &thd_body, &t, NULL));
} }
gpr_mu_lock(&t.mu); gpr_mu_lock(&t.mu);
...@@ -97,10 +98,10 @@ static void test(void) { ...@@ -97,10 +98,10 @@ static void test(void) {
gpr_mu_unlock(&t.mu); gpr_mu_unlock(&t.mu);
GPR_ASSERT(t.n == 0); GPR_ASSERT(t.n == 0);
gpr_thd_options_set_joinable(&options); gpr_thd_options_set_joinable(&options);
for (i = 0; i < n; i++) { for (i = 0; i < NUM_THREADS; i++) {
GPR_ASSERT(gpr_thd_new(&thds[i], &thd_body_joinable, NULL, &options)); GPR_ASSERT(gpr_thd_new(&thds[i], &thd_body_joinable, NULL, &options));
} }
for (i = 0; i < n; i++) { for (i = 0; i < NUM_THREADS; i++) {
gpr_thd_join(thds[i]); gpr_thd_join(thds[i]);
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment