summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_thread_pool.h
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2017-01-17 20:00:00 +0300
committerIgor Sysoev <igor@sysoev.ru>2017-01-17 20:00:00 +0300
commit16cbf3c076a0aca6d47adaf3f719493674cf2363 (patch)
treee6530480020f62a2bdbf249988ec3e2a751d3927 /src/nxt_thread_pool.h
downloadunit-16cbf3c076a0aca6d47adaf3f719493674cf2363.tar.gz
unit-16cbf3c076a0aca6d47adaf3f719493674cf2363.tar.bz2
Initial version.
Diffstat (limited to 'src/nxt_thread_pool.h')
-rw-r--r--src/nxt_thread_pool.h41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/nxt_thread_pool.h b/src/nxt_thread_pool.h
new file mode 100644
index 00000000..eb359260
--- /dev/null
+++ b/src/nxt_thread_pool.h
@@ -0,0 +1,41 @@
+
+/*
+ * Copyright (C) Igor Sysoev
+ * Copyright (C) NGINX, Inc.
+ */
+
+#ifndef _NXT_UNIX_THREAD_POOL_H_INCLUDED_
+#define _NXT_UNIX_THREAD_POOL_H_INCLUDED_
+
+
+typedef void (*nxt_thread_pool_init_t)(void);
+
+
+struct nxt_thread_pool_s {
+ nxt_atomic_t ready;
+ nxt_atomic_t waiting;
+ nxt_atomic_t threads;
+ nxt_uint_t max_threads;
+
+ nxt_sem_t sem;
+ nxt_nsec_t timeout;
+
+ nxt_locked_work_queue_t work_queue;
+
+ nxt_thread_handle_t main;
+
+ nxt_event_engine_t *engine;
+ nxt_thread_pool_init_t init;
+ nxt_work_handler_t exit;
+};
+
+
+NXT_EXPORT nxt_thread_pool_t *nxt_thread_pool_create(nxt_uint_t max_threads,
+ nxt_nsec_t timeout, nxt_thread_pool_init_t init,
+ nxt_event_engine_t *engine, nxt_work_handler_t exit);
+NXT_EXPORT void nxt_thread_pool_destroy(nxt_thread_pool_t *tp);
+NXT_EXPORT nxt_int_t nxt_thread_pool_post(nxt_thread_pool_t *tp,
+ nxt_work_handler_t handler, void *obj, void *data, nxt_log_t *log);
+
+
+#endif /* _NXT_UNIX_THREAD_POOL_H_INCLUDED_ */