Fdhvdu / ThreadPool

A fastest, exception-safety and pure C++17 thread pool.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

thread pool max threads

mohsenomidi opened this issue · comments

@Fdhvdu

i want to know if i defined the pool with max size 10 and some part of my code based on receiving requests add_and_detach the thread to this pool once the threadpool max size exceeds what will happen ?

i need to know the excess threads will wait to finished the current number of threads and once the working threads release/finished, the waited threads will execute ?
or all the new threads fired immediately without controlling on the max size of pool ?

i want to know if i defined the pool with max size 10 and some part of my code based on receiving requests add_and_detach the thread to this pool once the threadpool max size exceeds what will happen ?

For add_and_detach, if request number is greater than maximum number that thread pool has, it will block there. If a thread in thread pool complete its job, the requests get a thread and run.

i need to know the excess threads will wait to finished the current number of threads and once the working threads release/finished, the waited threads will execute ?

Yes. Once a thread in thread pool is available, one of the excess threads will run.