Skip to content
Open
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
4 changes: 2 additions & 2 deletions include/asioexec/completion_token.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ namespace asioexec {
template <typename T, typename... Us>
requires std::constructible_from<Initiation, T>
&& std::constructible_from<args_type_, Us...>
explicit constexpr sender(T&& t, Us&&... us) noexcept(
constexpr explicit sender(T&& t, Us&&... us) noexcept(
std::is_nothrow_constructible_v<Initiation, T>
&& std::is_nothrow_constructible_v<args_type_, Us...>)
: init_(static_cast<T&&>(t))
Expand Down Expand Up @@ -429,7 +429,7 @@ namespace asioexec {
};
}
public:
explicit constexpr executor(
constexpr explicit executor(
operation_state_base<Signatures, Receiver>& self,
const Executor& ex) noexcept
: self_(self)
Expand Down
79 changes: 42 additions & 37 deletions include/exec/async_scope.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ namespace exec {
struct __t : __task {
using __id = __when_empty_op;

explicit __t(const __impl* __scope, _Constrained&& __sndr, _Receiver __rcvr)
constexpr explicit __t(const __impl* __scope, _Constrained&& __sndr, _Receiver __rcvr)
: __task{{}, __scope, __notify_waiter}
, __op_(
STDEXEC::connect(
Expand Down Expand Up @@ -101,7 +101,7 @@ namespace exec {
}

private:
static void __notify_waiter(__task* __self) noexcept {
static constexpr void __notify_waiter(__task* __self) noexcept {
STDEXEC::start(static_cast<__t*>(__self)->__op_);
}

Expand Down Expand Up @@ -206,7 +206,7 @@ namespace exec {
__complete(__scope);
}

void set_stopped() noexcept
constexpr void set_stopped() noexcept
requires __callable<set_stopped_t, _Receiver>
{
auto __scope = __op_->__scope_;
Expand All @@ -216,7 +216,7 @@ namespace exec {
__complete(__scope);
}

auto get_env() const noexcept -> __env_t<env_of_t<_Receiver>> {
constexpr auto get_env() const noexcept -> __env_t<env_of_t<_Receiver>> {
return make_env(
STDEXEC::get_env(__op_->__rcvr_),
STDEXEC::prop{get_stop_token, __op_->__scope_->__stop_source_.get_token()});
Expand All @@ -236,12 +236,12 @@ namespace exec {
connect_result_t<_Constrained, __nest_rcvr_t> __op_;

template <__decays_to<_Constrained> _Sender, __decays_to<_Receiver> _Rcvr>
explicit __t(const __impl* __scope, _Sender&& __c, _Rcvr&& __rcvr)
constexpr explicit __t(const __impl* __scope, _Sender&& __c, _Rcvr&& __rcvr)
: __nest_op_base<_ReceiverId>{{}, __scope, static_cast<_Rcvr&&>(__rcvr)}
, __op_(STDEXEC::connect(static_cast<_Sender&&>(__c), __nest_rcvr_t{this})) {
}

void start() & noexcept {
constexpr void start() & noexcept {
STDEXEC_ASSERT(this->__scope_);
auto& __active = this->__scope_->__active_;
__active.fetch_add(1, __std::memory_order_relaxed);
Expand Down Expand Up @@ -313,7 +313,7 @@ namespace exec {
struct __subscription : __immovable {
void (*__complete_)(__subscription*) noexcept = nullptr;

void __complete() noexcept {
constexpr void __complete() noexcept {
__complete_(this);
}

Expand All @@ -330,7 +330,7 @@ namespace exec {
using __forward_consumer =
stop_token_of_t<env_of_t<_Receiver>>::template callback_type<__forward_stopped>;

void __complete_() noexcept {
constexpr void __complete_() noexcept {
STDEXEC_TRY {
__forward_consumer_.reset();
auto __state = std::move(__state_);
Expand Down Expand Up @@ -379,7 +379,7 @@ namespace exec {
public:
using __id = __future_op;

~__t() noexcept {
constexpr ~__t() noexcept {
if (__state_ != nullptr) {
auto __raw_state = __state_.get();
std::unique_lock __guard{__raw_state->__mutex_};
Expand All @@ -395,7 +395,9 @@ namespace exec {
}

template <class _Receiver2>
explicit __t(_Receiver2&& __rcvr, std::unique_ptr<__future_state<_Sender, _Env>> __state)
constexpr explicit __t(
_Receiver2&& __rcvr,
std::unique_ptr<__future_state<_Sender, _Env>> __state)
: __subscription{
{},
[](__subscription* __self) noexcept -> void {
Expand All @@ -409,7 +411,7 @@ namespace exec {
__forward_stopped{&__state_->__stop_source_}) {
}

void start() & noexcept {
constexpr void start() & noexcept {
STDEXEC_TRY {
if (!!__state_) {
std::unique_lock __guard{__state_->__mutex_};
Expand Down Expand Up @@ -442,7 +444,7 @@ namespace exec {
#else

template <class _Tag, class... _Ts>
auto __completion_as_tuple_(_Tag (*)(_Ts...)) -> std::tuple<_Tag, _Ts...>;
constexpr auto __completion_as_tuple_(_Tag (*)(_Ts...)) -> std::tuple<_Tag, _Ts...>;

template <class _Fn>
using __completion_as_tuple_t = decltype(__scope::__completion_as_tuple_(
Expand Down Expand Up @@ -472,7 +474,7 @@ namespace exec {

template <class _Ty>
struct __dynamic_delete {
__dynamic_delete()
constexpr __dynamic_delete()
: __delete_([](_Ty* __p) { delete __p; }) {
}

Expand All @@ -489,7 +491,7 @@ namespace exec {
return *this;
}

void operator()(_Ty* __p) {
constexpr void operator()(_Ty* __p) {
__delete_(__p);
}

Expand All @@ -498,7 +500,7 @@ namespace exec {

template <class _Completions, class _Env>
struct __future_state_base {
__future_state_base(_Env __env, const __impl* __scope)
constexpr __future_state_base(_Env __env, const __impl* __scope)
: __forward_scope_{
std::in_place,
__scope->__stop_source_.get_token(),
Expand All @@ -519,7 +521,7 @@ namespace exec {
}
}

void __step_from_to_(
constexpr void __step_from_to_(
std::unique_lock<std::mutex>& __guard,
__future_step __from,
__future_step __to) {
Expand Down Expand Up @@ -548,7 +550,7 @@ namespace exec {
__future_state_base<_Completions, _Env>* __state_;
const __impl* __scope_;

void __dispatch_result_(std::unique_lock<std::mutex>& __guard) noexcept {
constexpr void __dispatch_result_(std::unique_lock<std::mutex>& __guard) noexcept {
auto& __state = *__state_;
auto __local_subscribers = std::move(__state.__subscribers_);
__state.__forward_scope_.reset();
Expand All @@ -568,7 +570,7 @@ namespace exec {
}

template <class _Tag, class... _As>
void __save_completion(_Tag, _As&&... __as) noexcept {
constexpr void __save_completion(_Tag, _As&&... __as) noexcept {
auto& __state = *__state_;
STDEXEC_TRY {
using _Tuple = __decayed_std_tuple<_Tag, _As...>;
Expand All @@ -581,29 +583,29 @@ namespace exec {
}

template <__movable_value... _As>
void set_value(_As&&... __as) noexcept {
constexpr void set_value(_As&&... __as) noexcept {
auto& __state = *__state_;
std::unique_lock __guard{__state.__mutex_};
__save_completion(set_value_t(), static_cast<_As&&>(__as)...);
__dispatch_result_(__guard);
}

template <__movable_value _Error>
void set_error(_Error&& __err) noexcept {
constexpr void set_error(_Error&& __err) noexcept {
auto& __state = *__state_;
std::unique_lock __guard{__state.__mutex_};
__save_completion(set_error_t(), static_cast<_Error&&>(__err));
__dispatch_result_(__guard);
}

void set_stopped() noexcept {
constexpr void set_stopped() noexcept {
auto& __state = *__state_;
std::unique_lock __guard{__state.__mutex_};
__save_completion(set_stopped_t());
__dispatch_result_(__guard);
}

auto get_env() const noexcept -> const __env_t<_Env>& {
constexpr auto get_env() const noexcept -> const __env_t<_Env>& {
return __state_->__env_;
}
};
Expand All @@ -617,12 +619,12 @@ namespace exec {
struct __future_state : __future_state_base<__future_completions_t<_Sender, _Env>, _Env> {
using _Completions = __future_completions_t<_Sender, _Env>;

__future_state(connect_t, _Sender&& __sndr, _Env __env, const __impl* __scope)
constexpr __future_state(connect_t, _Sender&& __sndr, _Env __env, const __impl* __scope)
: __future_state_base<_Completions, _Env>(static_cast<_Env&&>(__env), __scope)
, __op_(static_cast<_Sender&&>(__sndr), __future_receiver_t<_Sender, _Env>{this, __scope}) {
}

__future_state(_Sender __sndr, _Env __env, const __impl* __scope)
constexpr __future_state(_Sender __sndr, _Env __env, const __impl* __scope)
: __future_state(
STDEXEC::connect,
static_cast<_Sender&&>(__sndr),
Expand Down Expand Up @@ -691,7 +693,7 @@ namespace exec {
private:
friend struct async_scope;

explicit __t(std::unique_ptr<__future_state<_Sender, _Env>> __state) noexcept
constexpr explicit __t(std::unique_ptr<__future_state<_Sender, _Env>> __state) noexcept
: __state_(std::move(__state)) {
std::unique_lock __guard{__state_->__mutex_};
__state_->__step_from_to_(__guard, __future_step::__created, __future_step::__future);
Expand All @@ -713,12 +715,12 @@ namespace exec {
inplace_stop_token __token_;

[[nodiscard]]
auto query(get_stop_token_t) const noexcept -> inplace_stop_token {
constexpr auto query(get_stop_token_t) const noexcept -> inplace_stop_token {
return __token_;
}

[[nodiscard]]
auto query(get_scheduler_t) const noexcept -> STDEXEC::inline_scheduler {
constexpr auto query(get_scheduler_t) const noexcept -> STDEXEC::inline_scheduler {
return {};
}
};
Expand All @@ -742,7 +744,7 @@ namespace exec {
using receiver_concept = STDEXEC::receiver_t;
__spawn_op_base<_EnvId>* __op_;

void set_value() noexcept {
constexpr void set_value() noexcept {
__op_->__delete_(__op_);
}

Expand All @@ -752,11 +754,11 @@ namespace exec {
std::rethrow_exception(std::move(__eptr));
}

void set_stopped() noexcept {
constexpr void set_stopped() noexcept {
__op_->__delete_(__op_);
}

auto get_env() const noexcept -> const __spawn_env_t<_Env>& {
constexpr auto get_env() const noexcept -> const __spawn_env_t<_Env>& {
return __op_->__env_;
}
};
Expand All @@ -771,7 +773,7 @@ namespace exec {
using _Sender = STDEXEC::__t<_SenderId>;

struct __t : __spawn_op_base<_EnvId> {
__t(connect_t, _Sender&& __sndr, _Env __env, const __impl* __scope)
constexpr __t(connect_t, _Sender&& __sndr, _Env __env, const __impl* __scope)
: __spawn_op_base<_EnvId>{
__env::__join(
static_cast<_Env&&>(__env),
Expand All @@ -780,7 +782,7 @@ namespace exec {
, __data_(static_cast<_Sender&&>(__sndr), __spawn_receiver_t<_Env>{this}) {
}

__t(_Sender __sndr, _Env __env, const __impl* __scope)
constexpr __t(_Sender __sndr, _Env __env, const __impl* __scope)
: __t(
STDEXEC::connect,
static_cast<_Sender&&>(__sndr),
Expand All @@ -807,12 +809,12 @@ namespace exec {

template <sender _Constrained>
[[nodiscard]]
auto when_empty(_Constrained&& __c) const -> __when_empty_sender_t<_Constrained> {
constexpr auto when_empty(_Constrained&& __c) const -> __when_empty_sender_t<_Constrained> {
return __when_empty_sender_t<_Constrained>{&__impl_, static_cast<_Constrained&&>(__c)};
}

[[nodiscard]]
auto on_empty() const {
constexpr auto on_empty() const {
return when_empty(just());
}

Expand All @@ -821,7 +823,7 @@ namespace exec {

template <sender _Constrained>
[[nodiscard]]
auto nest(_Constrained&& __c) -> nest_result_t<_Constrained> {
constexpr auto nest(_Constrained&& __c) -> nest_result_t<_Constrained> {
return nest_result_t<_Constrained>{&__impl_, static_cast<_Constrained&&>(__c)};
}

Expand All @@ -837,18 +839,21 @@ namespace exec {
}

template <__movable_value _Env = env<>, sender_in<__env_t<_Env>> _Sender>
[[nodiscard]]
auto spawn_future(_Sender&& __sndr, _Env __env = {}) -> __future_t<_Sender, _Env> {
using __state_t = __future_state<nest_result_t<_Sender>, _Env>;
auto __state = std::make_unique<__state_t>(
nest(static_cast<_Sender&&>(__sndr)), static_cast<_Env&&>(__env), &__impl_);
return __future_t<_Sender, _Env>{std::move(__state)};
}

auto get_stop_source() noexcept -> inplace_stop_source& {
[[nodiscard]]
constexpr auto get_stop_source() noexcept -> inplace_stop_source& {
return __impl_.__stop_source_;
}

auto get_stop_token() const noexcept -> inplace_stop_token {
[[nodiscard]]
constexpr auto get_stop_token() const noexcept -> inplace_stop_token {
return __impl_.__stop_source_.get_token();
}

Expand Down
6 changes: 3 additions & 3 deletions include/exec/completion_signatures.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ namespace exec {
// make_completion_signatures
namespace detail {
template <class Tag, class... As>
auto normalize_impl(As&&...) -> Tag (*)(As...);
constexpr auto normalize_impl(As&&...) -> Tag (*)(As...);

template <class Tag, class... As>
auto normalize(Tag (*)(As...))
constexpr auto normalize(Tag (*)(As...))
-> decltype(detail::normalize_impl<Tag>(STDEXEC::__declval<As>()...));

template <class... Sigs>
auto make_unique(Sigs*...)
constexpr auto make_unique(Sigs*...)
-> STDEXEC::__mapply_q<STDEXEC::completion_signatures, STDEXEC::__mmake_set<Sigs...>>;

template <class... Sigs>
Expand Down
4 changes: 2 additions & 2 deletions include/exec/finally.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ namespace exec {
void set_value() noexcept {
STDEXEC_TRY {
auto& __result = __op_->__result_.__get();
__result.visit(__visitor{}, static_cast<_ResultType&&>(__result), __op_);
STDEXEC::__visit(__visitor{}, static_cast<_ResultType&&>(__result), __op_);
}
STDEXEC_CATCH_ALL {
if constexpr (!__mapply_q<__nothrow_decay_copyable_t, _ResultType>::value) {
Expand Down Expand Up @@ -185,7 +185,7 @@ namespace exec {
.template emplace<__decayed_tuple<_Args...>>(static_cast<_Args&&>(__args)...);
STDEXEC_ASSERT(__op_.index() == 0);
auto __final = static_cast<_FinalSender&&>(__op_.template get<0>().__sndr_);
__final_op_t& __final_op = __op_.template emplace_from_at<1>(
__final_op_t& __final_op = __op_.template __emplace_from<1>(
STDEXEC::connect, static_cast<_FinalSender&&>(__final), __final_receiver_t{this});
STDEXEC::start(__final_op);
}
Expand Down
Loading
Loading