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 11 typedef void (*nxt_thread_pool_init_t)(void); 12 13 14 struct 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_work_t work; 24 nxt_task_t task; 25 26 nxt_locked_work_queue_t work_queue; 27 28 nxt_thread_handle_t main; 29 30 nxt_event_engine_t *engine; 31 nxt_thread_pool_init_t init; 32 nxt_work_handler_t exit; 33 }; 34 35 36 NXT_EXPORT nxt_thread_pool_t *nxt_thread_pool_create(nxt_uint_t max_threads, 37 nxt_nsec_t timeout, nxt_thread_pool_init_t init, 38 nxt_event_engine_t *engine, nxt_work_handler_t exit); 39 NXT_EXPORT void nxt_thread_pool_destroy(nxt_thread_pool_t *tp); 40 NXT_EXPORT nxt_int_t nxt_thread_pool_post(nxt_thread_pool_t *tp, 41 nxt_work_t *work); 42 43 44 #endif /* _NXT_UNIX_THREAD_POOL_H_INCLUDED_ */ 45