소스 검색

create enough threads

ithewei 3 년 전
부모
커밋
bbd6ae7fb3
1개의 변경된 파일1개의 추가작업 그리고 1개의 파일을 삭제
  1. 1 1
      cpputil/hthreadpool.h

+ 1 - 1
cpputil/hthreadpool.h

@@ -123,7 +123,7 @@ public:
     template<class Fn, class... Args>
     auto commit(Fn&& fn, Args&&... args) -> std::future<decltype(fn(args...))> {
         if (status == STOP) start();
-        if (idle_thread_num == 0 && cur_thread_num < max_thread_num) {
+        if (idle_thread_num <= tasks.size() && cur_thread_num < max_thread_num) {
             createThread();
         }
         using RetType = decltype(fn(args...));