aboutsummaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2020-02-24 05:57:35 -0800
committerGarrett D'Amore <garrett@damore.org>2020-02-24 05:57:35 -0800
commit15869e302e4f15c4c46bf5dc4bdf2aea96f513e0 (patch)
treec968153f00357aac482e5cc8555f8d2bb83a415d /CMakeLists.txt
parent4f7cf93dd0d9c37c7e5c6ec31d057f7cb3714a9c (diff)
downloadnng-15869e302e4f15c4c46bf5dc4bdf2aea96f513e0.tar.gz
nng-15869e302e4f15c4c46bf5dc4bdf2aea96f513e0.tar.bz2
nng-15869e302e4f15c4c46bf5dc4bdf2aea96f513e0.zip
fixes #1202 More than 120 threads was started by NNG
This introduces a new CMake option, NNG_MAX_TASKQ_THREADS, with a default value of 16. The number of taskq workers will generally be calculated as vcpu * 2. This new value, if not zero, sets an upper bound. Note that the value should be at least two, in order to ensure no deadlocks occur.
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt8
1 files changed, 7 insertions, 1 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9685713b..f74a13c1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -135,6 +135,12 @@ if (NNG_NUM_TASKQ_THREADS)
endif ()
mark_as_advanced(NNG_NUM_TASKQ_THREADS)
+set(NNG_MAX_TASKQ_THREADS 16 CACHE STRING "Upper bound on taskq threads, 0 for no limit")
+mark_as_advanced(NNG_MAX_TASKQ_THREADS)
+if (NNG_MAX_TASKQ_THREADS)
+ add_definitions(-DNNG_MAX_TASKQ_THREADS=${NNG_MAX_TASKQ_THREADS})
+endif ()
+
# Platform checks.
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
@@ -152,7 +158,7 @@ endif ()
include(CheckAtomicLib)
CheckAtomicLib()
if (NOT HAVE_C_ATOMICS_WITHOUT_LIB AND HAVE_C_ATOMICS_WITH_LIB)
- list(APPEND NNG_LIBS "atomic")
+ list(APPEND NNG_LIBS "atomic")
endif ()