9#include "MantidParallel/Communicator.h"
10#include "MantidParallel/DllConfig.h"
31 template <
class Function,
class... Args>
void runSerial(Function &&f, Args &&...args);
32 template <
class Function,
class... Args>
void runParallel(Function &&f, Args &&...args);
35 std::shared_ptr<Mantid::Parallel::detail::ThreadingBackend>
m_backend;
40 f(Mantid::Parallel::Communicator(
m_serialBackend, 0), std::forward<Args>(args)...);
45 Mantid::Parallel::Communicator comm;
46 f(comm, std::forward<Args>(args)...);
48 std::vector<std::thread> threads;
49 for (
int t = 0; t <
m_backend->size(); ++t) {
50 Mantid::Parallel::Communicator comm(
m_backend, t);
51 threads.emplace_back(std::forward<Function>(f), comm, std::forward<Args>(args)...);
53 for (
auto &t : threads) {
Runs a callable in parallel.
void runSerial(Function &&f, Args &&...args)
std::shared_ptr< Mantid::Parallel::detail::ThreadingBackend > m_backend
void runParallel(Function &&f, Args &&...args)
std::shared_ptr< Mantid::Parallel::detail::ThreadingBackend > m_serialBackend
void runParallel(Args &&...args)