Skip to content

repeat_* sender completion signature oddities. #1782

@justend29

Description

@justend29

Two questions about some unexpected behaviours of the repeat_ family of senders in the exec namespace:

  1. repeat_effect completely omits completion signatures.

    Although I presume this was done because the sender never completes on the value channel, it's counterintuitive and extremely limiting to omit the completion signatures. Where repeat_effect means "repeat upstream sender until error or exception", I immediately presumed the completion signatures would simply never contain set_value_t(). Without advertising completion signatures, any sender using repeat_effect essentially cannot be composed with any further senders. Examples that won't compile:

       auto snd_1 = stdexec::just_stopped()
          | exec::repeat_effect()
          | stdexec::upon_stopped([](){return -1;}); // cannot chain w/o completion_signatures
      // starts_on tries to transform completion signatures that don't exist
      exec::timed_thread_context ctx{};
      auto snd_2 = stdexec::starts_on(ctx.get_scheduler(), stdexec::just_stopped() | exec::repeat_effect());

    Is this intentional or a bug? If it's intentional, how is repeat_effect supposed to be used?

  2. repeat_effect_until and repeat_n add stdexec::set_stopped_t() to the completion signatures.

    Where the upstream senders in the following two examples complete only on the value channel, why would the repeat adapters transform the completion signatures as such? I gather that the stdexec::set_error_t(std::exception_ptr) signature is added to account for possible exceptions within the repeat_* machinery, and querying all the exception guarantees of creating the op-state to conditionally add an error channel would be difficult. Is the stop channel similarly added as a blanket solution?

      auto snd = stdexec::just(false) | exec::repeat_effect_until();
      static_assert(std::same_as<
        stdexec::completion_signatures_of_t<decltype(snd)>, 
        stdexec::completion_signatures<
          stdexec::set_stopped_t(),
          stdexec::set_error_t(std::exception_ptr),
          stdexec::set_value_t()
        >
      >);
    
      auto snd_n = stdexec::just() | exec::repeat_n(3);
      static_assert(std::same_as<
        stdexec::completion_signatures_of_t<decltype(snd_n)>, 
        stdexec::completion_signatures<
          stdexec::set_value_t(),
          stdexec::set_stopped_t(),
          stdexec::set_error_t(std::exception_ptr)
        >
      >);

Thanks for any feedback!

Examples were tested with the current tip of main, 8cfc3f1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions