Skip to content

Commit 6d1434f

Browse files
authored
give a better diagnostic for trying to use stdexec::task without a start scheduler (#2015)
* give a better diagnostic for trying to use `stdexec::task` without a start scheduler
1 parent ce822db commit 6d1434f

3 files changed

Lines changed: 126 additions & 109 deletions

File tree

include/stdexec/__detail/__spawn_future.hpp

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -246,22 +246,10 @@ namespace STDEXEC
246246
template <class _Alloc, scope_token _Token, sender _Sender, class _Env>
247247
struct __spawn_future_state final
248248
: __spawn_future_state_base<
249-
// the spec says completion_signatures_of_t<__future_spawned_sender<_Sender, _Env>> but
250-
// that breaks with an inscrutable error for _Sender = starts_on(sched, just() | then(...))
251-
//
252-
// I managed to fix the break by adding an extra _Env to the query, like so:
253-
//
254-
// completion_signatures_of_t<__future_spawned_sender<_Sender, _Env>, _Env>
255-
//
256-
// but that's hard to justify--the future-spawned-sender will be connected to a receiver
257-
// with an empty environment after all. This code works; I don't understand why the extra
258-
// env type changes the result, but this is a reasonably small change we can make to the
259-
// spec to bring things into alignment.
249+
// NOT TO SPEC: see https://github.com/cplusplus/sender-receiver/issues/356
260250
completion_signatures_of_t<__future_spawned_sender<_Sender, _Env>, env<>>>
261251
{
262-
using __sigs_t =
263-
// this is "wrong" in the same way as the above
264-
completion_signatures_of_t<__future_spawned_sender<_Sender, _Env>, env<>>;
252+
using __sigs_t = completion_signatures_of_t<__future_spawned_sender<_Sender, _Env>, env<>>;
265253

266254
using __receiver_t = __spawn_future_receiver<__sigs_t>;
267255

@@ -664,16 +652,16 @@ namespace STDEXEC
664652
template <sender _Sender, scope_token _Token, class _Env>
665653
auto __impl(_Sender&& __sndr, _Token&& __tkn, _Env&& __env) const
666654
{
667-
using __alloc_t = decltype(__spawn_common::__choose_alloc(__env, get_env(__sndr)));
668-
using __senv_t = decltype(__spawn_common::__choose_senv(__env, get_env(__sndr)));
655+
using __alloc_t = decltype(__spawn_common::__choose_alloc(__env, STDEXEC::get_env(__sndr)));
656+
using __senv_t = decltype(__spawn_common::__choose_senv(__env, STDEXEC::get_env(__sndr)));
669657

670658
using __spawn_future_state_t =
671659
__spawn_future_state<__alloc_t, std::remove_cvref_t<_Token>, _Sender, __senv_t>;
672660

673661
using __traits =
674662
std::allocator_traits<__alloc_t>::template rebind_traits<__spawn_future_state_t>;
675663
typename __traits::allocator_type __alloc(
676-
__spawn_common::__choose_alloc(__env, get_env(__sndr)));
664+
__spawn_common::__choose_alloc(__env, STDEXEC::get_env(__sndr)));
677665

678666
auto* __op = __traits::allocate(__alloc, 1);
679667

@@ -684,7 +672,7 @@ namespace STDEXEC
684672
__alloc,
685673
static_cast<_Sender&&>(__sndr),
686674
static_cast<_Token&&>(__tkn),
687-
__spawn_common::__choose_senv(__env, get_env(__sndr)));
675+
__spawn_common::__choose_senv(__env, STDEXEC::get_env(__sndr)));
688676

689677
__guard.__dismiss();
690678

include/stdexec/__detail/__stop_when.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,10 @@ namespace STDEXEC
6868
struct __stop_when_impl : __sexpr_defaults
6969
{
7070
template <class _Sender, class... _Env>
71-
static consteval auto __get_completion_signatures() //
72-
-> __completion_signatures_of_t<__child_of<_Sender>, _Env...>
71+
static consteval auto __get_completion_signatures()
7372
{
7473
static_assert(__sender_for<_Sender, __stop_when_t>);
75-
return {};
74+
return get_completion_signatures<__child_of<_Sender>, _Env...>();
7675
};
7776

7877
static constexpr auto __get_env = [](__ignore, auto const & __state) noexcept

0 commit comments

Comments
 (0)