forked from lwg/issues
-
Notifications
You must be signed in to change notification settings - Fork 28
New issue from Dietmar Kühl: task is not actually started lazily #482
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?xml version='1.0' encoding='utf-8' standalone='no'?> | ||
<!DOCTYPE issue SYSTEM "lwg-issue.dtd"> | ||
|
||
<issue num="4349" status="New"> | ||
<title><code>task</code> is not actually started lazily</title> | ||
<section><sref ref="[task.promise]"/></section> | ||
<submitter>Dietmar Kühl</submitter> | ||
<date>01 Sep 2025</date> | ||
<priority>99</priority> | ||
|
||
<discussion> | ||
<p> | ||
The wording for <code>task<...>::promise_type::initial_suspend</code> | ||
in <paper num="[task.promise]"/> paragraph 6 | ||
(second bullet) may imply that a task is eagerly started, i.e., that the | ||
awaiter return from <code>initial_suspend()</code> immediately starts | ||
the scheduling operation and cause the <code>task</code> 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. | ||
</p> | ||
<p> | ||
An alternative resolution it have <code>initial_suspend()</code> | ||
return <code>std::suspend_always</code> implicitly requiring that | ||
the <code>task</code> gets <code>start()</code>ed from the correct | ||
execution context. This approach has the advantage of avoiding | ||
unnecessary scheduling operations for the likely common case when | ||
<code>task</code>s are started from the correct context. | ||
</p> | ||
</discussion> | ||
|
||
<resolution> | ||
<p> | ||
Change the declaration of <code>initial_suspend()</code> in the synopsis | ||
of <sref ref="[task.promise]"/> to use | ||
<code>suspend_always</code>, directly provide a definition, and add | ||
various qualifiers: | ||
<blockquote> | ||
<pre> | ||
namespace std::execution { | ||
template<class T, class Environment> | ||
class task<T, Environment>::promise_type { | ||
... | ||
<del>auto</del><ins>static constexpr suspend_always</ins> initial_suspend() noexcept<del>;</del><ins>{ return {}; }</ins> | ||
... | ||
}; | ||
|
||
} | ||
</pre> | ||
</blockquote> | ||
</p> | ||
<p> | ||
Remove <sref ref="[task.promise]"/> paragraph 6 entirely: | ||
<blockquote> | ||
<pre><del>auto initial_suspend() noexcept;</del></pre> | ||
<p><del>-6- <i>Returns:</i> An awaitable object of unspecified type ([expr.await]) whose member functions arrange for</del></p> | ||
<p><del>-6.1- - the calling coroutine to be suspended,</del></p> | ||
<p><del>-6.2- - the coroutine to be resumed on an execution agent of the execution resource associated with <code><i>SCHED</i>(*this)</code>.</del></p> | ||
</blockquote> | ||
</p> | ||
</resolution> | ||
|
||
</issue> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.