Skip to content

Commit 7803838

Browse files
committed
New issue from Lewis Baker: "Reconsider weakly_parallel as the default forward_progress_guarantee"
1 parent a2eebee commit 7803838

File tree

1 file changed

+81
-0
lines changed

1 file changed

+81
-0
lines changed

xml/issue4354.xml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
<?xml version='1.0' encoding='utf-8' standalone='no'?>
2+
<!DOCTYPE issue SYSTEM "lwg-issue.dtd">
3+
4+
<issue num="4354" status="New">
5+
<title>Reconsider `weakly_parallel` as the default `forward_progress_guarantee`</title>
6+
<section>
7+
<sref ref="[exec.get.fwd.progress]"/>
8+
</section>
9+
<submitter>Lewis Baker</submitter>
10+
<date>25 Aug 2025</date>
11+
<priority>99</priority>
12+
13+
<discussion>
14+
<p>
15+
The `get_forward_progress_guarantee` CPO is intended to allow querying a scheduler as for what sort of
16+
forward-progress guarantee it provides. Algorithms may use this to determine whether it is safe to execute
17+
certain operations on a given scheduler. If a scheduler does not customize this query, the query will
18+
fall back to returning a forward-progress guarantee of weakly_parallel.
19+
<p/>
20+
I think we should reconsider what this default should be returning and suggest it should instead return
21+
`parallel` by default, as this will be by far the most common kind of scheduler, i.e. a scheduler that
22+
executes on `std::thread`-like execution agents and that maintains a queue of scheduled tasks.
23+
<p/>
24+
I expect it to be common that authors of schedulers may forget to customize the
25+
`get_forward_progress_guarantee_t` query and just leave it at the default. This will likely leave their
26+
scheduler reporting a weaker guarantee than it actually provides and thus not being usable within generic
27+
algorithms that require at least parallel forward progress.
28+
<p/>
29+
For example, the `run_loop` execution context defined in <sref ref="[exec.run.loop]"/> does not define
30+
its scheduler to customize the `get_forward_progress_guarantee_t`. This means it will report the default
31+
value of `weakly_parallel`.
32+
<p/>
33+
However, the scheduled operations will run on the thread that calls `run_loop::run()` and thus will
34+
inherit its forward-progress guarantees. As this function might block and is therefore unsafe to invoke
35+
it from a thread/agent with `weakly_parallel` forward progress guarantees (which should probably be
36+
explicitly specified as having undefined-behaviour) we can safely assume that `run_loop`'s scheduler
37+
can provide parallel forward-progress guarantee.
38+
<p/>
39+
It's not clear whether the current `run_loop` specification defaulting to its scheduler having
40+
`weakly_parallel` forward progress guarantee is intentional or unintentional here. However, forgetting
41+
to define the `get_forward_progress_guarantee` query on a scheduler is something I expect to be fairly common.
42+
<p/>
43+
Schedulers that provide `weakly_parallel` (or in future, `concurrent`) forward progress guarantees require
44+
implementations to be much more aware of the fact that these are the guarantees they are providing and
45+
thus could be more expected to customize the `get_forward_progress_guarantee` query to return the
46+
respective values.
47+
</p>
48+
</discussion>
49+
50+
<resolution>
51+
<p>
52+
This wording is relative to <paper num="N5014"/>.
53+
</p>
54+
55+
<ol>
56+
57+
<li><p>Modify <sref ref="[exec.get.fwd.progress]"/> as indicated:</p>
58+
59+
<blockquote>
60+
<p>
61+
-2- The name `get_forward_progress_guarantee` denotes a query object. For a subexpression `sch`, let `Sch`
62+
be `decltype((sch))`. If `Sch` does not satisfy `scheduler`, `get_forward_progress_guarantee` is ill-formed.
63+
Otherwise, `get_forward_progress_guarantee(sch)` is expression-equivalent to:
64+
</p>
65+
<ol style="list-style-type: none">
66+
<li><p>(2.1) &mdash; <tt><i>MANDATE-NOTHROW</i>(<i>AS-CONST</i>(sch).query(get_forward_progress_guarantee))</tt>
67+
if that expression is well-formed.
68+
<p/>
69+
<i>Mandates</i>: The type of the expression above is `forward_progress_guarantee`.
70+
</p></li>
71+
<li><p>(2.2) &mdash; Otherwise, <tt>forward_progress_guarantee::<del>weakly_</del>parallel</tt>.</p></li>
72+
</ol>
73+
74+
</blockquote>
75+
76+
</li>
77+
78+
</ol>
79+
</resolution>
80+
81+
</issue>

0 commit comments

Comments
 (0)