diff options
author | Guangxiong Lin <[email protected]> | 2022-12-16 19:08:35 +0800 |
---|---|---|
committer | Guangxiong Lin <[email protected]> | 2022-12-16 19:08:35 +0800 |
commit | 1def149b9245563a8ba1db9e937d537da8de8d27 (patch) | |
tree | a4da52a57ebc29afee13242d85c386a37945c92f | |
parent | 7369505397cdfddf0883e2c24e1652df8bd488fe (diff) | |
download | tinyserver-1def149b9245563a8ba1db9e937d537da8de8d27.tar.gz tinyserver-1def149b9245563a8ba1db9e937d537da8de8d27.tar.bz2 tinyserver-1def149b9245563a8ba1db9e937d537da8de8d27.zip |
Update default threads created
-rw-r--r-- | src/tpool.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/tpool.c b/src/tpool.c index 1aa5986..46213ff 100644 --- a/src/tpool.c +++ b/src/tpool.c @@ -1,5 +1,7 @@ #include <pthread.h> #include <stdlib.h> +#include <sys/sysinfo.h> + #include "tpool.h" struct tpool_work { @@ -102,8 +104,8 @@ tpool_t *tpool_create(size_t num) tpool_t *tp; pthread_t thread; - if (num == 0) - num = 12; + if (num <= 0) + num = get_nprocs(); tp = (tpool_t *)malloc(sizeof(*tp)); tp->thread_cnt = num; |