12 template<
typename Impl,
typename... Types>
15 template<
typename Impl,
typename Type,
typename... Rest>
17 using RestType =
typename Impl::template RMType<Impl, Rest...>;
26 using ThisRMType =
typename Impl::template RMType<Impl, Type, Rest...>;
27 ((ThisRMType*)
this)->setFunc(rm.
m_func);
31 using ThisRMType =
typename Impl::template RMType<Impl, Type, Rest...>;
33 ((ThisRMType*)
this)->setFunc(other.
m_func);
57 template<
typename Impl>
60 template<
typename F,
typename... Args>
61 typename std::result_of<F(Args...)>::type
call(
const F& func, Args&& ... args) {
62 return func(std::forward<Args>(args)...);
67 template<
typename Impl,
typename... Types>
77 ParallelWrapper(
int nthreads) : m_impl(nthreads) { m_impl.init(m_resource_manager); }
82 template<
typename PrevResMan>
84 : m_impl(impl), m_resource_manager(prev_rm) {
85 m_impl.init(m_resource_manager);
91 template<
typename IndexF,
typename IndexL,
typename Func>
92 void for_(IndexF first, IndexL last,
const Func& f) {
96 template<
typename IndexF,
typename IndexL,
typename IndexS,
typename Func>
97 void for_(IndexF first, IndexL last, IndexS step,
const Func& f) {
98 m_impl.parallelFor(first, last, step, f, m_resource_manager);
106 auto p =
ParallelWrapper<Impl, T, Types...>(m_impl, m_resource_manager);
112 template<
typename T,
typename Func>
114 return withFunc(std::function<T()>(f));
117 template<
typename T,
typename... Args>
119 return withFunc<T>(std::function<T()>([=]() {
125 return m_resource_manager;
133 Impl&
impl() {
return m_impl; }
135 const Impl&
impl()
const {
return m_impl; }
ParallelWrapper< Impl, T, Types... > with(Args...args)
int getNumThreads() const
void for_(IndexF first, IndexL last, const Func &f)
const Impl & impl() const
ParallelWrapper(const Impl &impl)
std::function< Type()> FuncType
void setFunc(const FuncType &f)
ResourceManager< Impl, Type, Rest... > & operator=(const ResourceManager< Impl, Type, Rest... > &other)
std::result_of< F(Args...)>::type call(const F &func, Args &&...args)
ResourceManager(const ResourceManager< Impl, Type, Rest... > &rm)
ParallelWrapper(int nthreads)
ParallelWrapper(Impl &impl, PrevResMan &prev_rm)
const RestType & rest() const
typename Impl::template RMType< Impl, Types... > RMType
ParallelWrapper< Impl, T, Types... > withFunc(const std::function< T()> &f)
ResourceManager(const RestType &rest)
RMType m_resource_manager
void for_(IndexF first, IndexL last, IndexS step, const Func &f)
typename Impl::template RMType< Impl, Rest... > RestType
ParallelWrapper< Impl, T, Types... > withFunc(const Func &f)
is_cond<(sizeof(T1) > sizeof(T2)), T1, T2 >::type type
void setNumThreads(int nthreads)