hpx::future<FwdIter> rotate_helper(ExPolicy const& policy, FwdIter first, FwdIter new_first, FwdIter last) { typedef boost::mpl::false_ non_seq; task_execution_policy p = task(policy.get_executor(), policy.get_chunk_size()); detail::reverse r; return lcos::local::dataflow( hpx::util::unwrapped([=]() mutable { hpx::future<void> f = r.call(p, first, last, non_seq()); std::advance(first, std::distance(new_first, last)); return f.then( [first] (hpx::future<void> &&) -> FwdIter { return first; }); }), r.call(p, first, new_first, non_seq()), r.call(p, new_first, last, non_seq())); }
// requires traits::is_future<Future> std::size_t get_static_chunk_size(ExPolicy policy, std::vector<Future>& workitems, F1 && f1, FwdIter& first, std::size_t& count, std::size_t chunk_size) { if (chunk_size == 0) { chunk_size = policy.get_chunk_size(); if (chunk_size == 0) { typedef typename ExPolicy::executor_type executor_type; std::size_t const cores = executor_traits<executor_type>:: os_thread_count(policy.executor()); if (count > 100*cores) chunk_size = auto_chunk_size(workitems, f1, first, count); if (chunk_size == 0) chunk_size = (count + cores - 1) / cores; } } return chunk_size; }