26 template <
class Executor,
class Allocator = std::allocator<
char>>
36 using RS = decltype(selector);
37 using F = std::conditional_t<
41 using Out = decltype(out);
43 typename std::allocator_traits<Allocator>::template rebind_alloc<char>
45 auto shared_state = std::allocate_shared<std::tuple<
50 std::atomic<decltype(init(input))>,
51 std::atomic<std::size_t>,
52 std::atomic<std::size_t>
59 (decltype(func)&&)func,
63 e |
op::submit([e, sb, se, shared_state](
auto) {
64 auto stepDone = [](
auto shared_state) {
66 if (--std::get<5>(*shared_state) == 0) {
68 if (std::get<0>(*shared_state)) {
70 std::get<1>(*shared_state), std::get<0>(*shared_state));
75 auto result = std::get<2>(*shared_state)(
76 std::move(std::get<4>(*shared_state).load()));
80 std::get<1>(*shared_state), std::current_exception());
84 for (decltype(sb) idx{sb}; idx != se;
85 ++idx, ++std::get<5>(*shared_state)) {
86 e |
op::submit([shared_state, idx, stepDone](
auto ex) {
89 auto old = std::get<4>(*shared_state).load();
94 std::get<3> (*shared_state)(step, idx);
95 }
while (!std::get<4>(*shared_state)
96 .compare_exchange_strong(old, step));
99 if (std::get<6>(*shared_state)++ == 0) {
101 std::get<0>(*shared_state) = std::current_exception();
104 stepDone(shared_state);
107 stepDone(shared_state);
120 std::vector<int>
vec(10);
126 [](
int&
x) {
x = 42; });
129 std::count(vec.begin(), vec.end(), 42) == static_cast<int>(vec.size()));
131 std::cout <<
"OK" << std::endl;
constexpr detail::Map< Move > move
PUSHMI_INLINE_VAR constexpr __adl::set_error_fn set_error
auto naive_executor_bulk_target(Executor e, Allocator a=Allocator{})
void init(int *argc, char ***argv, bool removeFlags)
static const char *const value
PUSHMI_INLINE_VAR constexpr __adl::set_value_fn set_value
void for_each(T const &range, Function< void(typename T::value_type const &) const > const &func)