diff --git a/xml/issue4349.xml b/xml/issue4349.xml new file mode 100644 index 0000000000..1aada82a3c --- /dev/null +++ b/xml/issue4349.xml @@ -0,0 +1,63 @@ + + + + +<code>task</code> is not actually started lazily +
+Dietmar Kühl +01 Sep 2025 +99 + + +

+The wording for task<...>::promise_type::initial_suspend +in paragraph 6 +(second bullet) may imply that a task is eagerly started, i.e., that the +awaiter return from initial_suspend() immediately starts +the scheduling operation and cause the task to be resumed. At +the very least the second bullet of the wording should be clarified such +that the scheduling operation is only started when the coroutine gets +resumed. +

+

+An alternative resolution it have initial_suspend() +return std::suspend_always implicitly requiring that +the task gets start()ed from the correct +execution context. This approach has the advantage of avoiding +unnecessary scheduling operations for the likely common case when +tasks are started from the correct context. +

+
+ + +

+Change the declaration of initial_suspend() in the synopsis +of to use +suspend_always, directly provide a definition, and add +various qualifiers: +

+
+namespace std::execution {
+  template<class T, class Environment>
+  class task<T, Environment>::promise_type {
+    ...
+    autostatic constexpr suspend_always initial_suspend() noexcept;{ return {}; }
+    ...
+  };
+
+}
+
+
+

+

+Remove paragraph 6 entirely: +

+
auto initial_suspend() noexcept;
+

-6- Returns: An awaitable object of unspecified type ([expr.await]) whose member functions arrange for

+

-6.1- - the calling coroutine to be suspended,

+

-6.2- - the coroutine to be resumed on an execution agent of the execution resource associated with SCHED(*this).

+
+

+
+ +