static void create_worker_threads()

in threads.c [137:167]


static void create_worker_threads(struct tctl *ctl, struct netconsd_params *p)
{
	struct ncrx_worker *cur, *workers;
	int i, r;

	workers = calloc(p->nr_workers, sizeof(*workers));
	if (!workers)
		fatal("Couldn't allocate thread structures\n");

	for (i = 0; i < p->nr_workers; i++) {
		cur = &workers[i];

		pthread_mutex_init(&cur->queuelock, NULL);
		pthread_condattr_init(&cur->condattr);
		pthread_condattr_setclock(&cur->condattr, CLOCK_MONOTONIC);
		pthread_cond_init(&cur->cond, &cur->condattr);
		cur->queue_head = NULL;
		cur->thread_nr = i;

		cur->gc_int_ms = p->gc_int_ms;
		cur->gc_age_ms = p->gc_age_ms;
		cur->lastgc = p->gc_int_ms ? now_mono_ms() / p->gc_int_ms : 0;

		r = pthread_create(&cur->id, NULL, ncrx_worker_thread, cur);
		if (r)
			fatal("%d/%d failed: -%d\n", i, p->nr_workers, r);
	}

	ctl->nr_workers = p->nr_workers;
	ctl->workers = workers;
}