void runner(int id, int a, int b) {...}
void caller()
{
static ctpl::thread_pool pool(4);
for (int i = 0; i < nbThreads; i++) {
pool.push(runner, a, b);
}
pool.stop(true); // this kills all threads, meaning next time this function is called i have to create them again
}
So I'm using this library here: https://github.com/vit-vit/ctpl
However, in the example, I did not see any function to synchronize the threads. For std::thread, that would be th.join(). pool.get_thread(i).join() is not the solution; it freezes the because the thread is running always running to accept new commands, which is its intended behavior.
The only way I see that work is pool.stop(true). But if I do this, the threads are destroyed and I have to create them again next time, which defeats the point of a thread pool.
Can someone who use this library show me how to synchronize threads?