Penso che non sia ancora accettato in Boost, ma un buon punto di partenza: threadpool. Alcuni esempi di utilizzo, dal sito Web:
#include "threadpool.hpp"
using namespace boost::threadpool;
// Some example tasks
void first_task()
{
...
}
void second_task()
{
...
}
void third_task()
{
...
}
void execute_with_threadpool()
{
// Create a thread pool.
pool tp(2);
// Add some tasks to the pool.
tp.schedule(&first_task);
tp.schedule(&second_task);
tp.schedule(&third_task);
// Leave this function and wait until all tasks are finished.
}
L'argomento "2" per il pool indica il numero di thread. In questo caso, la distruzione di tp
attende la fine di tutti i thread.
fonte
2010-10-21 13:58:06
Qual è il problema con boost? –
@David - non c'è un threadpool integrato in Boost, c'è? –
@Steve Townsend: Giusto, scusa ... ho pensato di ricordarne uno in boost, ma non è realmente incluso (non è stato accettato). Ce n'è uno disponibile in http://threadpool.sourceforge.net/index.html –