-
Notifications
You must be signed in to change notification settings - Fork 0
/
sudoku_boost.cpp
47 lines (39 loc) · 1.37 KB
/
sudoku_boost.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// solver with SSE 4.2 / AVX
// Copyright (C) 2012-2016 Zettsu Tatsuya
// Boost C++ Libraries dependent implementation
#ifdef SOLVE_PARALLEL_WITH_BOOST_THREAD
#include "sudoku_boost_future.h"
#include "sudoku_os_dependent.h"
namespace Sudoku {
class BoostParallelRunner : public BaseParallelRunner {
public:
BoostParallelRunner(void) = default;
virtual ~BoostParallelRunner(void) = default;
protected:
virtual NumberOfCores getHardwareConcurrency(void) override;
virtual ResultType runParallel(EvaluatorSet& evaluatorSet) override;
};
BoostParallelRunner::NumberOfCores BoostParallelRunner::getHardwareConcurrency(void) {
return boost::thread::hardware_concurrency();
}
BoostParallelRunner::ResultType BoostParallelRunner::runParallel(EvaluatorSet& evaluatorSet) {
std::vector<boost::unique_future<ResultType>> futureSet;
for(auto& evaluator : evaluatorSet) {
futureSet.push_back(boost::async(boost::launch::async, evaluator));
}
return runParallelImpl(futureSet);
}
std::unique_ptr<BaseParallelRunner> CreateParallelRunner(void) {
std::unique_ptr<BaseParallelRunner> pObj(new BoostParallelRunner);
return pObj;
}
}
#endif // SOLVE_PARALLEL_WITH_BOOST_THREAD
/*
Local Variables:
mode: c++
coding: utf-8-unix
tab-width: nil
c-file-style: "stroustrup"
End:
*/