aboutsummaryrefslogtreecommitdiffstats
path: root/killbarriergroup.c
blob: f83317e64231ce0264d027cd5c6e812a746dcc1f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/* See LICENSE file for copyright and license details. */
#include "common.h"


void
killbarriergroup(struct barrier_group *group, struct global_data *global)
{
#ifndef SINGLE_THREADED
	size_t i;

	if (!group->nthreads)
		return;

	global->action = NULL;
	for (i = 0; i < group->nthreads; i++)
		group->threads[i].global = global;
	barrierwait(&group->barrier);

	for (i = 0; i < group->nthreads; i++)
		if ((errno = pthread_join(group->threads[i].thread, NULL)))
			weprintf("pthread_join:");
	pthread_barrier_destroy(&group->barrier);

	free(group->threads);
#else
	(void) group;
	(void) global;
#endif
}