21 #ifndef __TBB_parallel_for_each_H 22 #define __TBB_parallel_for_each_H 24 #include "parallel_do.h" 25 #include "parallel_for.h" 32 template <
typename Function,
typename Iterator>
33 class parallel_for_each_body_do : internal::no_assign {
34 const Function &my_func;
36 parallel_for_each_body_do(
const Function &_func) : my_func(_func) {}
38 void operator()(
typename std::iterator_traits<Iterator>::reference value)
const {
44 template <
typename Function,
typename Iterator>
45 class parallel_for_each_body_for : internal::no_assign {
46 const Function &my_func;
48 parallel_for_each_body_for(
const Function &_func) : my_func(_func) {}
54 for(Iterator it = range.
begin(), end = range.
end(); it != end; ++it) {
60 template<
typename Iterator,
typename Function,
typename Generic>
61 struct parallel_for_each_impl {
62 #if __TBB_TASK_GROUP_CONTEXT 63 static void doit(Iterator first, Iterator last,
const Function& f, task_group_context &context) {
64 internal::parallel_for_each_body_do<Function, Iterator> body(f);
68 static void doit(Iterator first, Iterator last,
const Function& f) {
69 internal::parallel_for_each_body_do<Function, Iterator> body(f);
73 template<
typename Iterator,
typename Function>
74 struct parallel_for_each_impl<Iterator, Function,
std::random_access_iterator_tag> {
75 #if __TBB_TASK_GROUP_CONTEXT 76 static void doit(Iterator first, Iterator last,
const Function& f, task_group_context &context) {
77 internal::parallel_for_each_body_for<Function, Iterator> body(f);
81 static void doit(Iterator first, Iterator last,
const Function& f) {
82 internal::parallel_for_each_body_for<Function, Iterator> body(f);
94 #if __TBB_TASK_GROUP_CONTEXT 95 template<
typename Iterator,
typename Function>
96 void parallel_for_each(Iterator first, Iterator last,
const Function& f, task_group_context &context) {
97 internal::parallel_for_each_impl<Iterator, Function, typename std::iterator_traits<Iterator>::iterator_category>::doit(first, last, f, context);
102 template<
typename Range,
typename Function>
104 parallel_for_each(tbb::internal::first(rng), tbb::internal::last(rng), f, context);
109 template<
typename Range,
typename Function>
111 parallel_for_each(tbb::internal::first(rng), tbb::internal::last(rng), f, context);
116 template<
typename Iterator,
typename Function>
118 internal::parallel_for_each_impl<Iterator, Function, typename std::iterator_traits<Iterator>::iterator_category>::doit(first, last, f);
122 template<
typename Range,
typename Function>
128 template<
typename Range,
typename Function>
const_iterator begin() const
Beginning of range.
Definition: blocked_range.h:62
Definition: _tbb_windef.h:37
A range over which to iterate.
Definition: blocked_range.h:40
const_iterator end() const
One past last value in range.
Definition: blocked_range.h:65
void parallel_for(const Range &range, const Body &body)
Parallel iteration over range with default partitioner.
Definition: parallel_for.h:185
void parallel_for_each(Iterator first, Iterator last, const Function &f, task_group_context &context)
Calls function f for all items from [first, last) interval using user-supplied context.
Definition: parallel_for_each.h:96
Definition: _flow_graph_async_msg_impl.h:32
The namespace tbb contains all components of the library.
Definition: parallel_for.h:44
void parallel_do(Iterator first, Iterator last, const Body &body)
Parallel iteration over a range, with optional addition of more work.
Definition: parallel_do.h:455