Ejemplo n.º 1
0
void
qb_atomic_init(void)
{
	if (qb_atomic_mutex == NULL) {
		qb_atomic_mutex = qb_thread_lock_create(QB_THREAD_LOCK_SHORT);
	}
	assert(qb_atomic_mutex);
}
Ejemplo n.º 2
0
void
qb_log_dcs_init(void)
{
	int32_t rc;

	lookup_arr = qb_array_create_2(16, sizeof(struct callsite_list), 1);
	callsite_arr = qb_array_create_2(16, sizeof(struct qb_log_callsite), 1);

	arr_next_lock = qb_thread_lock_create(QB_THREAD_LOCK_SHORT);

	callsite_elems_per_bin = qb_array_elems_per_bin_get(callsite_arr);
	rc = qb_array_new_bin_cb_set(callsite_arr, _log_register_callsites);
	assert(rc == 0);
}
Ejemplo n.º 3
0
int32_t
qb_log_thread_start(void)
{
	int res;

	if (wthread_active) {
		return 0;
	}

	wthread_active = QB_TRUE;
	sem_init(&logt_thread_start, 0, 0);
	sem_init(&logt_print_finished, 0, 0);
	res = pthread_create(&logt_thread_id, NULL,
			     qb_logt_worker_thread, NULL);
	if (res != 0) {
		wthread_active = QB_FALSE;
		return -res;
	}
	sem_wait(&logt_thread_start);

	if (logt_sched_param_queued) {
		res = qb_log_thread_priority_set(logt_sched_policy,
		                                 logt_sched_param.sched_priority);
		if (res != 0) {
			goto cleanup_pthread;
		}
		logt_sched_param_queued = QB_FALSE;
	}
	logt_wthread_lock = qb_thread_lock_create(QB_THREAD_LOCK_SHORT);
	if (logt_wthread_lock == NULL) {
		goto cleanup_pthread;
	}

	return 0;

cleanup_pthread:
	wthread_should_exit = QB_TRUE;
	sem_post(&logt_print_finished);
	pthread_join(logt_thread_id, NULL);
	sem_destroy(&logt_print_finished);
	sem_destroy(&logt_thread_start);

	return res;
}