Skip to content

Commit 88cd29b

Browse files
committed
New issue from Eric Niebler: "Late domain-based dispatching of schedule_from and continues_on are flipped"
1 parent b5d9789 commit 88cd29b

File tree

1 file changed

+117
-0
lines changed

1 file changed

+117
-0
lines changed

xml/issue4248.xml

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
<?xml version='1.0' encoding='utf-8' standalone='no'?>
2+
<!DOCTYPE issue SYSTEM "lwg-issue.dtd">
3+
4+
<issue num="4248" status="New">
5+
<title>Late domain-based dispatching of `schedule_from` and `continues_on` are flipped</title>
6+
<section>
7+
<sref ref="[exec.snd.expos]"/>
8+
</section>
9+
<submitter>Eric Niebler</submitter>
10+
<date>26 Apr 2025</date>
11+
<priority>99</priority>
12+
13+
<discussion>
14+
<p>
15+
The reason for having two different customization points for transitioning between two execution contexts
16+
is described in <sref ref="[exec.snd.expos]"/> bullet (14.1) Note 1, to wit:
17+
</p>
18+
<blockquote style="border-left: 3px solid #ccc;padding-left: 15px;">
19+
<p>
20+
[<i>Note 1</i>: The `continues_on` algorithm works in tandem with `schedule_from`
21+
(<sref ref="[exec.schedule.from]"/>) to give scheduler authors a way to customize
22+
both how to transition onto (`continues_on`) and off of (`schedule_from`) a given
23+
execution context. Thus, `continues_on` ignores the domain of the predecessor and
24+
uses the domain of the destination scheduler to select a customization, a property
25+
that is unique to `continues_on`. That is why it is given special treatment here.
26+
&mdash; <i>end note</i>]
27+
</p>
28+
</blockquote>
29+
<p>
30+
The exposition-only <tt><i>get-domain-late</i></tt> function treats `continues_on`
31+
senders specially to make sure the correct domain (that of the destination scheduler)
32+
is used to find customizations at connect time.
33+
<p/>
34+
However, customizations are also searched for early when the sender is first constructed.
35+
And here the dispatching of `continues_on` and `schedule_from` are reversed.
36+
<p/>
37+
`continues_on(sndr, sch)` is defined as (<sref ref="[exec.continues.on]"/>):
38+
</p>
39+
<blockquote><pre>
40+
transform_sender(<i>get-domain-early</i>(sndr), <i>make-sender</i>(continues_on, sch, sndr))
41+
</pre></blockquote>
42+
<p>
43+
which is using the domain of the predecessor rather than ignoring it as <sref ref="[exec.snd.expos]"/> p14.1
44+
says it does. And `schedule_from(sch, sndr)` is currently defined as (<sref ref="[exec.schedule.from]"/>):
45+
</p>
46+
<blockquote><pre>
47+
transform_sender(
48+
<i>query-or-default</i>(get_domain, sch, default_domain()),
49+
<i>make-sender</i>(schedule_from, sch, sndr))
50+
</pre></blockquote>
51+
<p>
52+
which is using the domain of the destination scheduler to find customizations. The logic for
53+
determining the domain to use for early customization of these two algorithms are opposite
54+
what they are for late customization. This is a bug. They should be consistent.
55+
<p/>
56+
"Lazy" customization (at connect time) was added to <paper num="P2300"/> later in the process,
57+
and this inconsistency was a mistake on my part. The correct thing to do is to change
58+
<tt><i>get-domain-late</i></tt> to treat `schedule_from` as special, not `continues_on`.
59+
</p>
60+
</discussion>
61+
62+
<resolution>
63+
<p>
64+
This wording is relative to <paper num="N5008"/>.
65+
</p>
66+
67+
<ol>
68+
69+
<li><p>Modify <sref ref="[exec.snd.expos]"/> as indicated:</p>
70+
71+
<blockquote>
72+
<pre>
73+
template&lt;class Sndr, class Env&gt;
74+
constexpr auto <i>get-domain-late</i>(const Sndr&amp; sndr, const Env&amp; env) noexcept;
75+
</pre>
76+
<blockquote>
77+
<p>
78+
-14- <i>Effects</i>: Equivalent to:
79+
</p>
80+
<ol style="list-style-type: none">
81+
<li><p>(14.1) &mdash; If <tt><i>sender-for</i>&lt;Sndr, <del>continues_on_t</del><ins>schedule_from_t</ins>&gt;</tt> is `true`, then</p>
82+
<blockquote><pre>
83+
return Domain();
84+
</pre></blockquote>
85+
<p>
86+
where `Domain` is the type of the following expression:
87+
</p>
88+
<blockquote><pre>
89+
[] {
90+
auto [_, sch, _] = sndr;
91+
return <i>query-or-default</i>(get_domain, sch, default_domain());
92+
}();
93+
</pre></blockquote>
94+
<p>
95+
[<i>Note 1</i>: The <tt><del>continues_on</del><ins>schedule_from</ins></tt> algorithm
96+
works in tandem with <tt><del>schedule_from</del><ins>continues_on</ins></tt>
97+
(<del><sref ref="[exec.schedule.from]"/></del><ins><sref ref="[exec.continues.on]"/></ins>)
98+
to give scheduler authors a way to customize both how to transition onto
99+
(<tt><del>continues_on</del><ins>schedule_from</ins></tt>) and off of
100+
(<tt><del>schedule_from</del><ins>continues_on</ins></tt>) a given execution context.
101+
Thus, <tt><del>continues_on</del><ins>schedule_from</ins></tt> ignores the domain of the
102+
predecessor and uses the domain of the destination scheduler to select a customization,
103+
a property that is unique to <tt><del>continues_on</del><ins>schedule_from</ins></tt>.
104+
That is why it is given special treatment here. &mdash; <i>end note</i>]
105+
</p>
106+
</li>
107+
<li><p>[&hellip;]</p></li>
108+
</ol>
109+
</blockquote>
110+
</blockquote>
111+
112+
</li>
113+
114+
</ol>
115+
</resolution>
116+
117+
</issue>

0 commit comments

Comments
 (0)