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_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 33 NXT_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); 36 NXT_EXPORT void nxt_thread_pool_destroy(nxt_thread_pool_t *tp); 37 NXT_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); 39 40 41 #endif /* _NXT_UNIX_THREAD_POOL_H_INCLUDED_ */ 42