jeudi 13 août 2020

C++ Thread Pool Library (CTPL) Resize after pushing all tasks

I'm using the CTPL library and in my code I create a thread pool with only one thread, and then push all the tasks that I want to execute in the queue. After that, while that thread is executing the tasks, I use another thread (that doesn't belong to the thread pool) to increase the number of threads in the thread pool, using the resize method. However, the resizing has no effect since the new threads I added do not execute anything, only the first thread (thread 0) executes the tasks that are still in the queue.

Does this happen because when I push the tasks they are automatically associated with a thread? And in my case, since when I push the tasks there is only the thread 0 in the thread pool, all functions become associated with that thread?

Also, is there a problem in calling resize from a function outside the thread pool?

Thank you in advance for your help!

Aucun commentaire:

Enregistrer un commentaire