libacfutils
A general purpose library of utility functions designed to make it easier to develop addons for the X-Plane flight simulator.
Loading...
Searching...
No Matches
taskq.h
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
7 * with the License.
8 *
9 * You can obtain a copy of the license in the file COPYING
10 * or http://www.opensource.org/licenses/CDDL-1.0.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
13 *
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file COPYING.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 *
20 * CDDL HEADER END
21 */
22/*
23 * Copyright 2020 Saso Kiselkov. All rights reserved.
24 */
25
26#ifndef _ACFUTILS_TASKQ_H_
27#define _ACFUTILS_TASKQ_H_
28
29#include <stdbool.h>
30#include <stdint.h>
31
32#ifdef __cplusplus
33extern "C" {
34#endif
35
36typedef struct taskq_s taskq_t;
37
38typedef void *(*taskq_init_thr_t)(void *userinfo);
39typedef void (*taskq_fini_thr_t)(void *userinfo, void *thr_info);
40typedef void (*taskq_proc_task_t)(void *userinfo, void *thr_info, void *task);
41typedef void (*taskq_discard_task_t)(void *userinfo, void *task);
42
43API_EXPORT taskq_t *taskq_alloc(unsigned num_threads_min,
44 unsigned num_threads_max, uint64_t thr_stop_delay_us,
45 taskq_init_thr_t init_func,taskq_fini_thr_t fini_func,
46 taskq_proc_task_t proc_func, taskq_discard_task_t discard_func,
47 void *userinfo);
48API_EXPORT void taskq_free(taskq_t *tq);
49
50API_EXPORT void taskq_submit(taskq_t *tq, void *task);
51API_EXPORT bool taskq_wants_shutdown(taskq_t *tq);
52
53API_EXPORT void taskq_set_num_threads_min(taskq_t *tq, unsigned n_threads_min);
54API_EXPORT unsigned taskq_get_num_threads_min(const taskq_t *tq);
55API_EXPORT void taskq_set_num_threads_max(taskq_t *tq, unsigned n_threads_max);
56API_EXPORT unsigned taskq_get_num_threads_max(const taskq_t *tq);
57API_EXPORT void taskq_set_thr_stop_delay(taskq_t *tq, uint64_t stop_delay_us);
58API_EXPORT uint64_t taskq_get_thr_stop_delay(const taskq_t *tq);
59
60#ifdef __cplusplus
61}
62#endif
63
64#endif /* _ACFUTILS_TASKQ_H_ */