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
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: Yes
AttributeMacros: [
STDEXEC_PARALLEL_SCHEDULER_INLINE
STDEXEC_PARALLEL_SCHEDULER_INLINE,
STDEXEC_IMMOVABLE_NO_UNIQUE_ADDRESS
]
BinPackArguments: false
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ci.cpu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ jobs:
# is cached by commit, so only bumping llvm_sha (or the image tag)
# triggers a rebuild. This is the only modules row: move it to a
# released Clang's image once one contains the fix.
- { name: "CPU (clang trunk, Debug, modules)", build: "Debug", tag: llvm22-cuda13.2, cxxstd: "23", cxxflags: "-stdlib=libc++", llvm_sha: f970f59a9d4e6b8738547d01bc33e8a12df5244b }
- { name: "CPU (clang 22, Release)", build: "Release", tag: llvm22-cuda13.2, cxxstd: "23", cxxflags: "-stdlib=libc++" }
- { name: "CPU (clang 22, Release, noexcept)", build: "Release", tag: llvm22-cuda13.2, cxxstd: "23", cxxflags: "-stdlib=libc++ -fno-exceptions" }
- { name: "CPU (clang trunk, Debug, modules)", build: "Debug", tag: llvm22-cuda13.2, cxxstd: "23", cxxflags: "-stdlib=libc++", llvm_sha: f970f59a9d4e6b8738547d01bc33e8a12df5244b }
- { name: "CPU (clang 22, Release)", build: "Release", tag: llvm22-cuda13.2, cxxstd: "23", cxxflags: "-stdlib=libc++ -DSTDEXEC_ENABLE_EXTRA_TYPE_CHECKING" }
- { name: "CPU (clang 22, Release, noexcept)", build: "Release", tag: llvm22-cuda13.2, cxxstd: "23", cxxflags: "-stdlib=libc++ -fno-exceptions" }
# TSan in Clang < 18 and GCC < 15 aborts at startup ("unexpected
# memory mapping") when high-entropy ASLR places the executable
# outside its fixed shadow layout; newer runtimes re-exec without
Expand Down
1 change: 0 additions & 1 deletion include/exec/detail/xorshift.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import stdexec;
STDEXEC_MODULE_EXPORT
namespace experimental::execution
{

class xorshift
{
public:
Expand Down
42 changes: 22 additions & 20 deletions include/exec/fork_join.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ namespace experimental::execution
{};

template <class Tag, class... Args>
using _cref_sig_t = Tag(Args const &...);
using _cref_sig_t = Tag(STDEXEC::__decay_t<Args> const &...);

// Given a set of async results, each of the form `tuple<Tag, Args...>`,
// compute the corresponding completion signatures, where each signature is
Expand Down Expand Up @@ -135,7 +135,7 @@ namespace experimental::execution
{
using operation_state_concept = STDEXEC::operation_state_tag;
using _env_t = STDEXEC::__fwd_env_t<STDEXEC::env_of_t<Rcvr>>;
using _child_completions_t = STDEXEC::__completion_signatures_of_t<Sndr, _env_t>;
using _child_completions_t = STDEXEC::completion_signatures_of_t<Sndr, _env_t>;
using _domain_t = STDEXEC::__completion_domain_of_t<STDEXEC::set_value_t, Sndr, _env_t>;
using _when_all_sndr_t =
_fork_join::_when_all_sndr_t<_child_completions_t, Closures, _domain_t>;
Expand Down Expand Up @@ -247,26 +247,28 @@ namespace experimental::execution

if constexpr (__minvocable_q<__completion_domain_of_t, set_value_t, _child_sndr_t, Env...>)
{
using _domain_t = __completion_domain_of_t<set_value_t, _child_sndr_t, Env...>;
using _child_t = __copy_cvref_t<Self, _child_sndr_t>;
using _child_completions_t = __completion_signatures_of_t<_child_t, __fwd_env_t<Env>...>;
using __decay_copyable_results_t = __decay_copyable_results_t<_child_completions_t>;
using _domain_t = __completion_domain_of_t<set_value_t, _child_sndr_t, Env...>;
using _child_t = __copy_cvref_t<Self, _child_sndr_t>;
auto _child_completions =
STDEXEC::get_completion_signatures<_child_t, __fwd_env_t<Env>...>();

if constexpr (!__valid_completion_signatures<_child_completions_t>)
STDEXEC_IF_OK(_child_completions)
{
return _child_completions_t{};
}
else if constexpr (!__decay_copyable_results_t::value)
{
return STDEXEC::__throw_compile_time_error< //
_WHAT_(_PREDECESSOR_RESULTS_ARE_NOT_DECAY_COPYABLE_),
_IN_ALGORITHM_(exec::fork_join_t)>();
}
else
{
using _sndr_t =
_fork_join::_when_all_sndr_t<_child_completions_t, _closures_t, _domain_t>;
return STDEXEC::get_completion_signatures<_sndr_t, __fwd_env_t<Env>...>();
using _child_completions_t = decltype(_child_completions);
using __decay_copyable_results_t = __decay_copyable_results_t<_child_completions_t>;

if constexpr (!__decay_copyable_results_t::value)
{
return STDEXEC::__throw_compile_time_error< //
_WHAT_(_PREDECESSOR_RESULTS_ARE_NOT_DECAY_COPYABLE_),
_IN_ALGORITHM_(exec::fork_join_t)>();
}
else
{
using _sndr_t =
_fork_join::_when_all_sndr_t<_child_completions_t, _closures_t, _domain_t>;
return STDEXEC::get_completion_signatures<_sndr_t, __fwd_env_t<Env>...>();
}
}
}
else if constexpr (sizeof...(Env) == 0)
Expand Down
4 changes: 3 additions & 1 deletion include/exec/repeat_until.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,10 @@ namespace experimental::execution
}
else
{
// The child is connected as an lvalue (see __opstate), so copying it
// can throw even when moving it cannot.
using __has_nothrow_connect_t =
__mbool<(__nothrow_connectable<__child_t, __receiver_archetype<_Env>> || ...)>;
__mbool<(__nothrow_connectable<__child_t &, __receiver_archetype<_Env>> || ...)>;
constexpr auto __eptr_sigs = __eptr_completion_unless_t<__has_nothrow_connect_t>();
constexpr auto __bouncer_sigs = exec::transform_completion_signatures(
get_completion_signatures<__bouncer_t, _Env...>(),
Expand Down
27 changes: 10 additions & 17 deletions include/exec/reschedule.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#pragma once

#include "../stdexec/execution.hpp"
#include "exec/completion_signatures.hpp"

namespace experimental::execution
{
Expand All @@ -28,24 +29,10 @@ namespace experimental::execution
using namespace STDEXEC;

struct reschedule_t;
template <class _Env>
using __no_scheduler_error =
__mexception<_WHAT_(_CANNOT_RESCHEDULE_),
_WHY_(_THE_CURRENT_EXECUTION_ENVIRONMENT_DOES_NOT_HAVE_A_START_SCHEDULER_),
_WHERE_(_IN_ALGORITHM_, reschedule_t),
_WITH_ENVIRONMENT_(_Env)>;

template <class _Env>
using __schedule_sender_t = schedule_result_t<__call_result_t<get_start_scheduler_t, _Env>>;

template <class _Env>
using __try_schedule_sender_t =
__minvoke<__mtry_catch_q<__schedule_sender_t, __q<__no_scheduler_error>>, _Env>;

template <class _Env>
using __completions =
__minvoke_q<__completion_signatures_of_t, __try_schedule_sender_t<_Env>, _Env>;

struct __scheduler
{
using scheduler_concept = scheduler_tag;
Expand All @@ -64,13 +51,19 @@ namespace experimental::execution
using sender_concept = sender_tag;

template <class _Self, class _Env>
static consteval auto get_completion_signatures() -> __completions<_Env>
static consteval auto get_completion_signatures()
{
return {};
if constexpr (!__callable<get_start_scheduler_t, _Env>)
return exec::throw_compile_time_error<
_WHAT_(_CANNOT_RESCHEDULE_),
_WHY_(_THE_CURRENT_EXECUTION_ENVIRONMENT_DOES_NOT_HAVE_A_START_SCHEDULER_),
_WHERE_(_IN_ALGORITHM_, reschedule_t),
_WITH_ENVIRONMENT_(_Env)>();
else
return STDEXEC::get_completion_signatures<__schedule_sender_t<_Env>, _Env>();
}

template <receiver _Receiver>
requires receiver_of<_Receiver, __completions<env_of_t<_Receiver>>>
auto connect(_Receiver __rcvr) const
-> connect_result_t<__schedule_sender_t<env_of_t<_Receiver>>, _Receiver>
{
Expand Down
15 changes: 10 additions & 5 deletions include/exec/sequence/merge_each.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1269,11 +1269,16 @@ namespace experimental::execution
struct __completions_fn
{
template <class... _Sequences>
using __f =
__minvoke_q<__concat_completion_signatures_t,
completion_signatures<set_stopped_t()>,
__sequence_aware_completion_signatures_of_t<__child_of<_Self>, _Env...>,
__sequence_aware_completion_signatures_of_t<_Sequences, _Env...>...>;
using __f = __minvoke_q<
__concat_completion_signatures_t,
// merge_each can always complete with set_value() (when
// all the nested sequences complete normally), with
// set_stopped(), and with an exception_ptr (errors from
// the sequence of sequences and failures to connect or
// start the error item are stored as one).
completion_signatures<set_value_t(), set_stopped_t(), set_error_t(std::exception_ptr)>,
__sequence_aware_completion_signatures_of_t<__child_of<_Self>, _Env...>,
__sequence_aware_completion_signatures_of_t<_Sequences, _Env...>...>;
};

template <class _Self, class... _Env>
Expand Down
2 changes: 1 addition & 1 deletion include/exec/sequence_senders.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@ namespace experimental::execution
}

template <class _Sequence, class... _Env>
requires sequence_sender<_Sequence, _Env...>
requires sequence_sender_in<_Sequence, _Env...>
using item_types_of_t = decltype(exec::__checked_item_types(STDEXEC::__declval<_Sequence>(),
STDEXEC::__declval<_Env>()...));
# else
Expand Down
19 changes: 16 additions & 3 deletions include/exec/when_any.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,23 @@ namespace experimental::execution
exec::decay_arguments<set_error_t, when_any_t>())...);
}

// The results storage is computed from the children's *undecayed*
// completions: whether storing a result can throw (and so needs an
// exception_ptr alternative) depends on the actual argument types, e.g.,
// copying an lvalue reference can be nothrow where moving the decayed
// value is not.
template <class... _Env, class... _CvSenders>
consteval auto __mk_storage_completions(__mlist_ptr<_CvSenders...>)
{
return exec::concat_completion_signatures(
STDEXEC::completion_signatures<set_stopped_t()>(),
STDEXEC::get_completion_signatures<_CvSenders, __env_t<_Env>...>()...);
}

template <class _Env, class... _CvSenders>
using __results_storage_t =
__mapply_q<__results_storage,
decltype(__when_any::__mk_completions<_Env>(__mlist_ptr<_CvSenders...>()))>;
using __results_storage_t = __mapply_q<__results_storage,
decltype(__when_any::__mk_storage_completions<_Env>(
__mlist_ptr<_CvSenders...>()))>;

// Forwards stop requests on the receiver's token to __stop_source_.
template <class _Receiver, class _ResultVariant>
Expand Down
59 changes: 40 additions & 19 deletions include/stdexec/__detail/__continues_on.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,15 @@ namespace STDEXEC
template <class _Scheduler, class _Sender, class _Receiver>
using __state_t = __state<_Scheduler,
__secondary_env_t<_Sender, env_of_t<_Receiver>, set_value_t>,
__storage_for_t<_Sender, env_of_t<_Receiver>>,
__storage_for_t<_Sender, __fwd_env_t<env_of_t<_Receiver>>>,
_Receiver>;

//! The environment of the receiver to which the scheduler's sender is
//! connected. This must match @c __receiver2::get_env().
template <class _Child, class _Env>
using __sch_sndr_env_t =
__join_env_t<__secondary_env_t<_Child, _Env, set_value_t> const &, _Env>;

//! @brief The @c continues_on sender's attributes.
template <class _Scheduler, class _Sender>
struct __attrs
Expand All @@ -134,6 +140,10 @@ namespace STDEXEC
using __env2_t = __secondary_env_t<_Sender, _Env, set_value_t>;
template <class _Env>
using __sch_env_t = __join_env_t<__env2_t<_Env>, _Env>;
// The environment of the receiver to which the schedule sender is
// connected; see __receiver2.
template <class _Env>
using __sch_sndr_env_t = __trnsfr::__sch_sndr_env_t<_Sender, _Env>;

template <class _Env>
constexpr auto __mk_sch_env(_Env&& __env) const noexcept -> __sch_env_t<_Env>
Expand All @@ -156,9 +166,9 @@ namespace STDEXEC
{
if constexpr (__sends<set_value_t, _Sender, __fwd_env_t<_Env>...>)
{
return !__cmplsigs::__partitions_of_t<completion_signatures_of_t<
_Sender,
__fwd_env_t<_Env>...>>::__nothrow_decay_copyable::__values::value;
using __completions_t = completion_signatures_of_t<_Sender, __fwd_env_t<_Env>...>;
return !__cmplsigs::__partitions_of_t<
__completions_t>::__nothrow_decay_copyable::__values::value;
}
}
return false;
Expand All @@ -182,27 +192,27 @@ namespace STDEXEC
// `void`) that the query would reject. Bail out before touching anything
// that could hard-error.
if constexpr (!__one_of<_SetTag, set_error_t, set_stopped_t>)
{
{ // NOLINT(bugprone-branch-clone)
return indeterminate_domain<>();
}
else if constexpr (__forwards_completion<_SetTag, _Env...>())
{
constexpr bool __own = __sends<_SetTag, _SchSndr, __env2_t<_Env>...>;
using _Fwd = __completion_domain_of_t<set_value_t, _SchSndr, __env2_t<_Env>...>;
constexpr bool __own = __sends<_SetTag, _SchSndr, __sch_sndr_env_t<_Env>...>;
using _Fwd = __completion_domain_of_t<set_value_t, _SchSndr, __sch_sndr_env_t<_Env>...>;
if constexpr (__own)
{
return __common_domain_t<
_Fwd,
__completion_domain_of_t<_SetTag, _SchSndr, __env2_t<_Env>...>>();
__completion_domain_of_t<_SetTag, _SchSndr, __sch_sndr_env_t<_Env>...>>();
}
else
{
return _Fwd();
}
}
else if constexpr (__sends<_SetTag, _SchSndr, __env2_t<_Env>...>)
else if constexpr (__sends<_SetTag, _SchSndr, __sch_sndr_env_t<_Env>...>)
{
return __completion_domain_of_t<_SetTag, _SchSndr, __env2_t<_Env>...>();
return __completion_domain_of_t<_SetTag, _SchSndr, __sch_sndr_env_t<_Env>...>();
}
else
{
Expand All @@ -215,7 +225,7 @@ namespace STDEXEC
template <class _SetTag, class... _Env>
static consteval bool __sch_sends() noexcept
{
return __sends<_SetTag, schedule_result_t<_Scheduler>, __env2_t<_Env>...>;
return __sends<_SetTag, schedule_result_t<_Scheduler>, __sch_sndr_env_t<_Env>...>;
}

_Scheduler __sch_;
Expand Down Expand Up @@ -284,8 +294,9 @@ namespace STDEXEC
template <__same_as<set_value_t> _SetTag, class... _Env>
[[nodiscard]]
constexpr auto query(get_completion_domain_t<_SetTag>, _Env const &...) const noexcept
-> __ensure_valid_domain_t<
__completion_domain_of_t<_SetTag, schedule_result_t<_Scheduler>, __env2_t<_Env>...>>
-> __ensure_valid_domain_t<__completion_domain_of_t<_SetTag,
schedule_result_t<_Scheduler>,
__sch_sndr_env_t<_Env>...>>
{
return {};
}
Expand All @@ -298,7 +309,7 @@ namespace STDEXEC
//! domain contributes too.
template <__one_of<set_error_t, set_stopped_t> _SetTag, class... _Env>
requires(__forwards_completion<_SetTag, _Env...>()
|| __sends<_SetTag, schedule_result_t<_Scheduler>, __env2_t<_Env>...>)
|| __sends<_SetTag, schedule_result_t<_Scheduler>, __sch_sndr_env_t<_Env>...>)
[[nodiscard]]
constexpr auto query(get_completion_domain_t<_SetTag>, _Env const &...) const noexcept
-> __ensure_valid_domain_t<decltype(__forwarded_domain<_SetTag, _Env...>())>
Expand All @@ -317,7 +328,7 @@ namespace STDEXEC
{
using _SchSender = schedule_result_t<_Scheduler>;
constexpr auto cb_sched =
STDEXEC::__get_completion_behavior<_Tag, _SchSender, __env2_t<_Env>...>();
STDEXEC::__get_completion_behavior<_Tag, _SchSender, __sch_sndr_env_t<_Env>...>();
constexpr auto cb_sndr =
STDEXEC::__get_completion_behavior<_Tag, _Sender, __fwd_env_t<_Env>...>();
return cb_sched | cb_sndr;
Expand Down Expand Up @@ -353,13 +364,15 @@ namespace STDEXEC
__decay_arguments<set_error_t, continues_on_t>());
}

template <class _Scheduler, class... _Env>
template <class _Child, class _Scheduler, class... _Env>
static consteval auto __get_scheduler_completions()
{
// The scheduler contributes only error and stopped completions; we
// ignore value completions here
// ignore value completions here. The schedule sender is connected to a
// receiver whose environment is __sch_sndr_env_t, not __fwd_env_t<_Env>.
return STDEXEC::__transform_completion_signatures(
STDEXEC::get_completion_signatures<schedule_result_t<_Scheduler>, __fwd_env_t<_Env>...>(),
STDEXEC::get_completion_signatures<schedule_result_t<_Scheduler>,
__sch_sndr_env_t<_Child, _Env>...>(),
__ignore_completion());
}

Expand All @@ -385,11 +398,19 @@ namespace STDEXEC
auto __child_completions = __get_child_completions<__child_t, _Env...>();
return STDEXEC::__concat_completion_signatures(
__child_completions,
__get_scheduler_completions<__scheduler_t, _Env...>(),
__get_scheduler_completions<__child_t, __scheduler_t, _Env...>(),
__eptr_completion_unless_t<
__nothrow_decay_copyable_results_t<decltype(__child_completions)>>());
}

// The child's completions are computed with __fwd_env_t<_Env>, so the child
// must be connected to a receiver whose environment is likewise forwarded.
static constexpr auto __get_env = []<class _State>(__ignore, _State const & __state) noexcept
-> __fwd_env_t<env_of_t<decltype(__state.__rcvr_)>>
{
return __fwd_env(STDEXEC::get_env(__state.__rcvr_));
};

static constexpr auto __get_state =
[]<class _Sender, class _Receiver>(_Sender&& __sndr, _Receiver&& __rcvr) noexcept(
__nothrow_constructible_from<__state_for_t<_Sender, _Receiver>,
Expand Down
12 changes: 8 additions & 4 deletions include/stdexec/__detail/__execution_fwd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,14 @@ namespace STDEXEC
struct receiver_tag;

// concept tag aliases for backwards compatibility:
STDEXEC_MODULE_EXPORT using sender_t = sender_tag;
STDEXEC_MODULE_EXPORT using operation_state_t = operation_state_tag;
STDEXEC_MODULE_EXPORT using scheduler_t = scheduler_tag;
STDEXEC_MODULE_EXPORT using receiver_t = receiver_tag;
STDEXEC_MODULE_EXPORT
using sender_t = sender_tag;
STDEXEC_MODULE_EXPORT
using operation_state_t = operation_state_tag;
STDEXEC_MODULE_EXPORT
using scheduler_t = scheduler_tag;
STDEXEC_MODULE_EXPORT
using receiver_t = receiver_tag;

template <class _Tag, class _Sndr, class... _Env>
STDEXEC_ATTRIBUTE(nodiscard, always_inline, host, device)
Expand Down
Loading
Loading