mirror of
https://github.com/slsdetectorgroup/aare.git
synced 2025-06-13 15:57:14 +02:00

Co-authored-by: Patrick <patrick.sieberer@psi.ch> Co-authored-by: JulianHeymes <julian.heymes@psi.ch> Co-authored-by: Dhanya Thattil <dhanya.thattil@psi.ch>
18 lines
504 B
C++
18 lines
504 B
C++
#include <thread>
|
|
#include <vector>
|
|
#include <utility>
|
|
|
|
namespace aare {
|
|
|
|
template<typename F>
|
|
void RunInParallel(F func, const std::vector<std::pair<int, int>>& tasks) {
|
|
// auto tasks = split_task(0, y.shape(0), n_threads);
|
|
std::vector<std::thread> threads;
|
|
for (auto &task : tasks) {
|
|
threads.push_back(std::thread(func, task.first, task.second));
|
|
}
|
|
for (auto &thread : threads) {
|
|
thread.join();
|
|
}
|
|
}
|
|
} // namespace aare
|