Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions include/async/algorithm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ struct value_transform_receiver {
}
}

auto get_env() {
return execution::get_env(dr_);
}

private:
Receiver dr_; // Downstream receiver.
[[no_unique_address]] F f_;
Expand All @@ -113,6 +117,10 @@ struct void_transform_receiver {
}
}

auto get_env() {
return execution::get_env(dr_);
}

private:
Receiver dr_; // Downstream receiver.
[[no_unique_address]] F f_;
Expand Down Expand Up @@ -281,6 +289,10 @@ struct [[nodiscard]] repeat_while_operation {
execution::set_value(s->dr_);
}

auto get_env() {
return execution::get_env(self_->dr_);
}

private:
repeat_while_operation *self_;
};
Expand Down Expand Up @@ -359,6 +371,10 @@ struct race_and_cancel_operation<Receiver, frg::tuple<Functors...>, std::index_s
execution::set_value(self_->r_);
}

auto get_env() {
return execution::get_env(self_->r_);
}

private:
race_and_cancel_operation *self_;
};
Expand Down Expand Up @@ -595,6 +611,10 @@ struct [[nodiscard]] sequence_operation {
execution::set_value(s->dr_, std::move(value));
}

auto get_env() {
return execution::get_env(self_->dr_);
}

private:
sequence_operation *self_;
};
Expand Down Expand Up @@ -657,6 +677,10 @@ struct when_all_operation {
execution::set_value(self_->dr_);
}

auto get_env() {
return execution::get_env(self_->dr_);
}

private:
when_all_operation *self_;
};
Expand Down
4 changes: 4 additions & 0 deletions include/async/cancellation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,10 @@ struct with_cancel_cb_operation {
self->complete_();
}

auto get_env() {
return execution::get_env(self->dr_);
}

with_cancel_cb_operation *self;
};
static_assert(Receives<intermediate_receiver, value_type>);
Expand Down
19 changes: 19 additions & 0 deletions include/async/execution.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,24 @@ struct set_value_cpo {
}
};

template<typename T>
concept get_env_member = requires(T &&obj) {
obj.get_env();
};

struct empty_env { };

struct get_env_cpo {
template<typename T>
auto operator() (T &&obj) {
if constexpr (get_env_member<T>) {
return obj.get_env();
} else {
return empty_env{};
}
}
};

} // namespace cpo_types

namespace execution {
Expand All @@ -121,6 +139,7 @@ namespace execution {
inline cpo_types::start_cpo start;
inline cpo_types::start_inline_cpo start_inline;
inline cpo_types::set_value_cpo set_value;
inline cpo_types::get_env_cpo get_env;
}

} // namespace async
2 changes: 2 additions & 0 deletions include/async/post-ack.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ struct post_ack_mechanism {
};

struct [[nodiscard]] post_sender {
using value_type = void;

friend sender_awaiter<post_sender> operator co_await (post_sender sender) {
return {std::move(sender)};
}
Expand Down
4 changes: 4 additions & 0 deletions include/async/wait-group.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,10 @@ struct [[nodiscard]] sender_ {
std::forward<Ts>(ts)...
);
}

auto get_env() {
return execution::get_env(op_.originalr_);
}
};

execution::operation_t<OriginalS, receiver_> originalop_;
Expand Down