boost::threadIs there any mechanism in the library for controlling how many threads (at best) are running at the same time?
In my case, it would be most convenient to run tags Nat the same time (N can be hundreds or several thousand):
std::vector<boost::thread*> vec;
for (int i = 0; i < N; ++i) {
vec.push_back(new boost::thread(my_fct));
}
for (int i = 0; i < N; ++i) {
vec[i]->join();
delete vec[i];
}
But I want Boost to transparently set a maximum of, say, 4 threads running at a time. (I use an 8-core machine, so I should not run more than 4 at a time.)
Of course, I could take care to start only 4 at a time, but the solution I ask for would be more transparent and convenient.
Frank source
share