Skip to content

run_loop should not have a set_error completion signature #351

@ericniebler

Description

@ericniebler

When run_loop was proposed, the only implementation we had synchronized with a mutex and a condition variable. Operations on those can theoretically throw exceptions, so run_loop got a set_error_t(exception_ptr) completion signature.

Since then, a lock-free implementation of run_loop has been found*. Atomic operations cannot fail with an exception, so an atomic run_loop can never complete with an error.

Proposed Wording

change the class synopsis of run_loop ([exec.run.loop.general]) as follows:

 namespace std::execution {
   class run_loop {
     // [exec.run.loop.types], associated types
     class run-loop-scheduler;                                   // exposition only
     class run-loop-sender;                                      // exposition only
     struct run-loop-opstate-base {                              // exposition only
-      virtual void execute() = 0;                               // exposition only
+      virtual void execute() noexcept = 0;                      // exposition only
       run_loop* loop;                                           // exposition only
       run-loop-opstate-base* next;                              // exposition only
     };
     template<class Rcvr>
       using run-loop-opstate = unspecified;                     // exposition only
 
     // [exec.run.loop.members], member functions
-    run-loop-opstate-base* pop-front();                         // exposition only
-    void push-back(run-loop-opstate-base*);                     // exposition only
+    run-loop-opstate-base* pop-front() noexcept;                // exposition only
+    void push-back(run-loop-opstate-base*) noexcept;            // exposition only
 
   public:
     // [exec.run.loop.ctor], constructor and destructor
     run_loop() noexcept;
     run_loop(run_loop&&) = delete;
     ~run_loop();
 
     // [exec.run.loop.members], member functions
-    run-loop-scheduler get_scheduler();
-    void run();
-    void finish();
+    run-loop-scheduler get_scheduler() noexcept;
+    void run() noexcept;
+    void finish() noexcept;
   };
 }

Change [exec.run.loop.types]/p5 as follows:

 run-loop-sender is an exposition-only type that satisfies sender.
 completion_signatures_of_t<run-loop-sender> is

-  completion_signatures<set_value_t(), set_error_t(exception_ptr), set_stopped_t()>
+  completion_signatures<set_value_t(), set_stopped_t()>

Change [exec.run.loop.types]/p9.3 as follows:

 The expression start(o) is equivalent to:

-  try {
     o.loop->push-back(addressof(o));
-  } catch(...) {
-    set_error(std::move(REC(o)), current_exception());
-  }

In [exec.run.loop.members], change the prototypes of the following member functions to add noexcept:

  • pop-front
  • push-back
  • get_scheduler
  • run
  • finish

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions