Skip to content

Commit 6e8c024

Browse files
committed
Minor code cleanup of tst_thread_dispatcher.
1 parent 84343e5 commit 6e8c024

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

tst_threads.c

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,8 @@ static inline void worker_barrier() {
8888
}
8989

9090

91-
static void * tst_thread_dispatcher (void * arg)
92-
{
93-
struct tst_thread_env_t * thread_env = (struct tst_thread_env_t*) arg;
91+
static void *tst_thread_dispatcher(void *arg) {
92+
struct tst_thread_env_t *thread_env = (struct tst_thread_env_t *) arg;
9493
tst_thread_cmd_t local_cmd = TST_THREAD_CMD_NULL;
9594
int local_cmd_count = 0;
9695

@@ -101,8 +100,7 @@ static void * tst_thread_dispatcher (void * arg)
101100
/*
102101
* Wait for tests to be dispatched and scheduled.
103102
*/
104-
while (TST_THREAD_CMD_FINALIZE != local_cmd)
105-
{
103+
while (TST_THREAD_CMD_FINALIZE != local_cmd) {
106104
const struct tst_env * env;
107105

108106
pthread_mutex_lock (&cmd_mutex);
@@ -133,26 +131,20 @@ static void * tst_thread_dispatcher (void * arg)
133131
tst_output_printf (DEBUG_LOG, TST_REPORT_MAX, "(Rank:%d; Thread:%d) tst_thread_dispatcher calling init\n",
134132
tst_global_rank, thread_env->thread_num);
135133
thread_env->tst_init_func (env);
136-
137-
worker_done();
138134
break;
139135

140136
case TST_THREAD_CMD_RUN:
141137
thread_env->state = TST_THREAD_STATE_CALLING_RUN;
142138
tst_output_printf (DEBUG_LOG, TST_REPORT_MAX, "(Rank:%d; Thread:%d) tst_thread_dispatcher calling run\n",
143139
tst_global_rank, thread_env->thread_num);
144140
thread_env->tst_run_func (env);
145-
146-
worker_done();
147141
break;
148142

149143
case TST_THREAD_CMD_CLEANUP:
150144
thread_env->state = TST_THREAD_STATE_CALLING_CLEANUP;
151145
tst_output_printf (DEBUG_LOG, TST_REPORT_MAX, "(Rank:%d; Thread:%d) tst_thread_dispatcher calling cleanup\n",
152146
tst_global_rank, thread_env->thread_num);
153147
thread_env->tst_cleanup_func (env);
154-
155-
worker_done();
156148
break;
157149

158150
case TST_THREAD_CMD_FINALIZE:
@@ -162,6 +154,7 @@ static void * tst_thread_dispatcher (void * arg)
162154
ERROR(EINVAL, "Unhandled cmd");
163155
}
164156
thread_env->state = TST_THREAD_STATE_IDLE;
157+
worker_done();
165158
}
166159
return NULL;
167160
}

0 commit comments

Comments
 (0)