nxt_thread_pool.h (0:a63ceefd6ab0) nxt_thread_pool.h (1:fdc027c56872)
1
2/*
3 * Copyright (C) Igor Sysoev
4 * Copyright (C) NGINX, Inc.
5 */
6
7#ifndef _NXT_UNIX_THREAD_POOL_H_INCLUDED_
8#define _NXT_UNIX_THREAD_POOL_H_INCLUDED_
9
10
11typedef void (*nxt_thread_pool_init_t)(void);
12
13
14struct nxt_thread_pool_s {
15 nxt_atomic_t ready;
16 nxt_atomic_t waiting;
17 nxt_atomic_t threads;
18 nxt_uint_t max_threads;
19
20 nxt_sem_t sem;
21 nxt_nsec_t timeout;
22
1
2/*
3 * Copyright (C) Igor Sysoev
4 * Copyright (C) NGINX, Inc.
5 */
6
7#ifndef _NXT_UNIX_THREAD_POOL_H_INCLUDED_
8#define _NXT_UNIX_THREAD_POOL_H_INCLUDED_
9
10
11typedef void (*nxt_thread_pool_init_t)(void);
12
13
14struct nxt_thread_pool_s {
15 nxt_atomic_t ready;
16 nxt_atomic_t waiting;
17 nxt_atomic_t threads;
18 nxt_uint_t max_threads;
19
20 nxt_sem_t sem;
21 nxt_nsec_t timeout;
22
23 nxt_task_t task;
24
23 nxt_locked_work_queue_t work_queue;
24
25 nxt_thread_handle_t main;
26
27 nxt_event_engine_t *engine;
28 nxt_thread_pool_init_t init;
29 nxt_work_handler_t exit;
30};
31
32
33NXT_EXPORT nxt_thread_pool_t *nxt_thread_pool_create(nxt_uint_t max_threads,
34 nxt_nsec_t timeout, nxt_thread_pool_init_t init,
35 nxt_event_engine_t *engine, nxt_work_handler_t exit);
36NXT_EXPORT void nxt_thread_pool_destroy(nxt_thread_pool_t *tp);
37NXT_EXPORT nxt_int_t nxt_thread_pool_post(nxt_thread_pool_t *tp,
25 nxt_locked_work_queue_t work_queue;
26
27 nxt_thread_handle_t main;
28
29 nxt_event_engine_t *engine;
30 nxt_thread_pool_init_t init;
31 nxt_work_handler_t exit;
32};
33
34
35NXT_EXPORT nxt_thread_pool_t *nxt_thread_pool_create(nxt_uint_t max_threads,
36 nxt_nsec_t timeout, nxt_thread_pool_init_t init,
37 nxt_event_engine_t *engine, nxt_work_handler_t exit);
38NXT_EXPORT void nxt_thread_pool_destroy(nxt_thread_pool_t *tp);
39NXT_EXPORT nxt_int_t nxt_thread_pool_post(nxt_thread_pool_t *tp,
38 nxt_work_handler_t handler, void *obj, void *data, nxt_log_t *log);
40 nxt_work_handler_t handler, nxt_task_t *task, void *obj, void *data);
39
40
41#endif /* _NXT_UNIX_THREAD_POOL_H_INCLUDED_ */
41
42
43#endif /* _NXT_UNIX_THREAD_POOL_H_INCLUDED_ */