Closed t-mat closed 10 years ago
Thanks for the PR... nice to learn this feature of C++ :)
Is it possible to have this use 1 vs N cores programmatically?
Yes, and no.
You can achieve 'single thread mode' by the following change :
- wg.push_back(std::async(std::launch::async, [&, y](unsigned int seed) {
+ wg.push_back(std::async(std::launch::deferred, [&, y](unsigned int seed) {
see also
But for now there is no convenient and standard way to limit the maximum amount of threads.
You can achive the feature by thread pool or std::condition_variable, but I think it is too much complicated for this kind of simple project.
Oh alright
If you use
g++
, please add-std=c++11 -pthread
to your command line option.