Thread pools implementation.
diff --git a/auto/configure b/auto/configure
index e8929b8..617d992 100755
--- a/auto/configure
+++ b/auto/configure
@@ -58,6 +58,7 @@
. auto/unix
fi
+. auto/threads
. auto/modules
. auto/lib/conf
diff --git a/auto/modules b/auto/modules
index 7885967..5a56957 100644
--- a/auto/modules
+++ b/auto/modules
@@ -432,6 +432,12 @@
modules="$CORE_MODULES $EVENT_MODULES"
+# thread pool module should be initialized after events
+if [ $USE_THREADS = YES ]; then
+ modules="$modules $THREAD_POOL_MODULE"
+fi
+
+
if [ $USE_OPENSSL = YES ]; then
modules="$modules $OPENSSL_MODULE"
CORE_DEPS="$CORE_DEPS $OPENSSL_DEPS"
diff --git a/auto/options b/auto/options
index 02affbd..763871f 100644
--- a/auto/options
+++ b/auto/options
@@ -190,6 +190,8 @@
--without-poll_module) EVENT_POLL=NONE ;;
--with-aio_module) EVENT_AIO=YES ;;
+ --with-threads) USE_THREADS=YES ;;
+
--with-file-aio) NGX_FILE_AIO=YES ;;
--with-ipv6) NGX_IPV6=YES ;;
@@ -351,6 +353,8 @@
--with-poll_module enable poll module
--without-poll_module disable poll module
+ --with-threads enable thread pool support
+
--with-file-aio enable file AIO support
--with-ipv6 enable IPv6 support
diff --git a/auto/sources b/auto/sources
index 1287782..e7f1058 100644
--- a/auto/sources
+++ b/auto/sources
@@ -193,6 +193,13 @@
POSIX_DEPS=src/os/unix/ngx_posix_config.h
+THREAD_POOL_MODULE=ngx_thread_pool_module
+THREAD_POOL_DEPS=src/core/ngx_thread_pool.h
+THREAD_POOL_SRCS="src/core/ngx_thread_pool.c
+ src/os/unix/ngx_thread_cond.c
+ src/os/unix/ngx_thread_mutex.c
+ src/os/unix/ngx_thread_id.c"
+
FREEBSD_DEPS="src/os/unix/ngx_freebsd_config.h src/os/unix/ngx_freebsd.h"
FREEBSD_SRCS=src/os/unix/ngx_freebsd_init.c
FREEBSD_SENDFILE_SRCS=src/os/unix/ngx_freebsd_sendfile_chain.c
diff --git a/auto/summary b/auto/summary
index b200906..1be975d 100644
--- a/auto/summary
+++ b/auto/summary
@@ -7,6 +7,10 @@
echo "Configuration summary"
+if [ $USE_THREADS = YES ]; then
+ echo " + using threads"
+fi
+
if [ $USE_PCRE = DISABLED ]; then
echo " + PCRE library is disabled"
diff --git a/auto/threads b/auto/threads
new file mode 100644
index 0000000..381f07a
--- /dev/null
+++ b/auto/threads
@@ -0,0 +1,20 @@
+
+# Copyright (C) Nginx, Inc.
+
+
+if [ $USE_THREADS = YES ]; then
+
+ if [ "$NGX_PLATFORM" = win32 ]; then
+ cat << END
+
+$0: --with-threads is not supported on Windows
+
+END
+ exit 1
+ fi
+
+ have=NGX_THREADS . auto/have
+ CORE_DEPS="$CORE_DEPS $THREAD_POOL_DEPS"
+ CORE_SRCS="$CORE_SRCS $THREAD_POOL_SRCS"
+ CORE_LIBS="$CORE_LIBS -lpthread"
+fi