|
| 1 | +<!DOCTYPE html> |
| 2 | +<html lang="en"> |
| 3 | +<head> |
| 4 | +<meta charset="utf-8"> |
| 5 | +<title>Issue 4248: Late domain-based dispatching of schedule_from and continues_on are flipped</title> |
| 6 | +<meta property="og:title" content="Issue 4248: Late domain-based dispatching of schedule_from and continues_on are flipped"> |
| 7 | +<meta property="og:description" content="C++ library issue. Status: New"> |
| 8 | +<meta property="og:url" content="https://cplusplus.github.io/LWG/issue4248.html"> |
| 9 | +<meta property="og:type" content="website"> |
| 10 | +<meta property="og:image" content="http://cplusplus.github.io/LWG/images/cpp_logo.png"> |
| 11 | +<meta property="og:image:alt" content="C++ logo"> |
| 12 | +<style> |
| 13 | + p {text-align:justify} |
| 14 | + li {text-align:justify} |
| 15 | + pre code.backtick::before { content: "`" } |
| 16 | + pre code.backtick::after { content: "`" } |
| 17 | + blockquote.note |
| 18 | + { |
| 19 | + background-color:#E0E0E0; |
| 20 | + padding-left: 15px; |
| 21 | + padding-right: 15px; |
| 22 | + padding-top: 1px; |
| 23 | + padding-bottom: 1px; |
| 24 | + } |
| 25 | + ins {background-color:#A0FFA0} |
| 26 | + del {background-color:#FFA0A0} |
| 27 | + table.issues-index { border: 1px solid; border-collapse: collapse; } |
| 28 | + table.issues-index th { text-align: center; padding: 4px; border: 1px solid; } |
| 29 | + table.issues-index td { padding: 4px; border: 1px solid; } |
| 30 | + table.issues-index td:nth-child(1) { text-align: right; } |
| 31 | + table.issues-index td:nth-child(2) { text-align: left; } |
| 32 | + table.issues-index td:nth-child(3) { text-align: left; } |
| 33 | + table.issues-index td:nth-child(4) { text-align: left; } |
| 34 | + table.issues-index td:nth-child(5) { text-align: center; } |
| 35 | + table.issues-index td:nth-child(6) { text-align: center; } |
| 36 | + table.issues-index td:nth-child(7) { text-align: left; } |
| 37 | + table.issues-index td:nth-child(5) span.no-pr { color: red; } |
| 38 | + @media (prefers-color-scheme: dark) { |
| 39 | + html { |
| 40 | + color: #ddd; |
| 41 | + background-color: black; |
| 42 | + } |
| 43 | + ins { |
| 44 | + background-color: #225522 |
| 45 | + } |
| 46 | + del { |
| 47 | + background-color: #662222 |
| 48 | + } |
| 49 | + a { |
| 50 | + color: #6af |
| 51 | + } |
| 52 | + a:visited { |
| 53 | + color: #6af |
| 54 | + } |
| 55 | + blockquote.note |
| 56 | + { |
| 57 | + background-color: rgba(255, 255, 255, .10) |
| 58 | + } |
| 59 | + } |
| 60 | +</style> |
| 61 | +</head> |
| 62 | +<body> |
| 63 | +<hr> |
| 64 | +<p><em>This page is a snapshot from the LWG issues list, see the <a href="lwg-active.html">Library Active Issues List</a> for more information and the meaning of <a href="lwg-active.html#New">New</a> status.</em></p> |
| 65 | +<h3 id="4248"><a href="lwg-active.html#4248">4248</a>. Late domain-based dispatching of <code class='backtick'>schedule_from</code> and <code class='backtick'>continues_on</code> are flipped</h3> |
| 66 | +<p><b>Section:</b> 33.9.2 <a href="https://wg21.link/exec.snd.expos">[exec.snd.expos]</a> <b>Status:</b> <a href="lwg-active.html#New">New</a> |
| 67 | + <b>Submitter:</b> Eric Niebler <b>Opened:</b> 2025-04-26 <b>Last modified:</b> 2025-04-27</p> |
| 68 | +<p><b>Priority: </b>Not Prioritized |
| 69 | +</p> |
| 70 | +<p><b>View other</b> <a href="lwg-index-open.html#exec.snd.expos">active issues</a> in [exec.snd.expos].</p> |
| 71 | +<p><b>View all other</b> <a href="lwg-index.html#exec.snd.expos">issues</a> in [exec.snd.expos].</p> |
| 72 | +<p><b>View all issues with</b> <a href="lwg-status.html#New">New</a> status.</p> |
| 73 | +<p><b>Discussion:</b></p> |
| 74 | +<p> |
| 75 | +The reason for having two different customization points for transitioning between two execution contexts |
| 76 | +is described in 33.9.2 <a href="https://wg21.link/exec.snd.expos">[exec.snd.expos]</a> bullet (14.1) Note 1, to wit: |
| 77 | +</p> |
| 78 | +<blockquote style="border-left: 3px solid #ccc;padding-left: 15px;"> |
| 79 | +<p> |
| 80 | +[<i>Note 1</i>: The <code class='backtick'>continues_on</code> algorithm works in tandem with <code class='backtick'>schedule_from</code> |
| 81 | +(33.9.12.5 <a href="https://wg21.link/exec.schedule.from">[exec.schedule.from]</a>) to give scheduler authors a way to customize |
| 82 | +both how to transition onto (<code class='backtick'>continues_on</code>) and off of (<code class='backtick'>schedule_from</code>) a given |
| 83 | +execution context. Thus, <code class='backtick'>continues_on</code> ignores the domain of the predecessor and |
| 84 | +uses the domain of the destination scheduler to select a customization, a property |
| 85 | +that is unique to <code class='backtick'>continues_on</code>. That is why it is given special treatment here. |
| 86 | +— <i>end note</i>] |
| 87 | +</p> |
| 88 | +</blockquote> |
| 89 | +<p> |
| 90 | +The exposition-only <code><i>get-domain-late</i></code> function treats <code class='backtick'>continues_on</code> |
| 91 | +senders specially to make sure the correct domain (that of the destination scheduler) |
| 92 | +is used to find customizations at connect time. |
| 93 | +<p/> |
| 94 | +However, customizations are also searched for early when the sender is first constructed. |
| 95 | +And here the dispatching of <code class='backtick'>continues_on</code> and <code class='backtick'>schedule_from</code> are reversed. |
| 96 | +<p/> |
| 97 | +<code class='backtick'>continues_on(sndr, sch)</code> is defined as (33.9.12.4 <a href="https://wg21.link/exec.continues.on">[exec.continues.on]</a>): |
| 98 | +</p> |
| 99 | +<blockquote><pre> |
| 100 | +transform_sender(<i>get-domain-early</i>(sndr), <i>make-sender</i>(continues_on, sch, sndr)) |
| 101 | +</pre></blockquote> |
| 102 | +<p> |
| 103 | +which is using the domain of the predecessor rather than ignoring it as 33.9.2 <a href="https://wg21.link/exec.snd.expos">[exec.snd.expos]</a> p14.1 |
| 104 | +says it does. And <code class='backtick'>schedule_from(sch, sndr)</code> is currently defined as (33.9.12.5 <a href="https://wg21.link/exec.schedule.from">[exec.schedule.from]</a>): |
| 105 | +</p> |
| 106 | +<blockquote><pre> |
| 107 | +transform_sender( |
| 108 | + <i>query-or-default</i>(get_domain, sch, default_domain()), |
| 109 | + <i>make-sender</i>(schedule_from, sch, sndr)) |
| 110 | +</pre></blockquote> |
| 111 | +<p> |
| 112 | +which is using the domain of the destination scheduler to find customizations. The logic for |
| 113 | +determining the domain to use for early customization of these two algorithms are opposite |
| 114 | +what they are for late customization. This is a bug. They should be consistent. |
| 115 | +<p/> |
| 116 | +"Lazy" customization (at connect time) was added to <a href="https://wg21.link/P2300" title=" `std::execution`">P2300</a> later in the process, |
| 117 | +and this inconsistency was a mistake on my part. The correct thing to do is to change |
| 118 | +<code><i>get-domain-late</i></code> to treat <code class='backtick'>schedule_from</code> as special, not <code class='backtick'>continues_on</code>. |
| 119 | +</p> |
| 120 | + |
| 121 | + |
| 122 | +<p id="res-4248"><b>Proposed resolution:</b></p> |
| 123 | +<p> |
| 124 | +This wording is relative to <a href="https://wg21.link/N5008">N5008</a>. |
| 125 | +</p> |
| 126 | + |
| 127 | +<ol> |
| 128 | + |
| 129 | +<li><p>Modify 33.9.2 <a href="https://wg21.link/exec.snd.expos">[exec.snd.expos]</a> as indicated:</p> |
| 130 | + |
| 131 | +<blockquote> |
| 132 | +<pre> |
| 133 | +template<class Sndr, class Env> |
| 134 | + constexpr auto <i>get-domain-late</i>(const Sndr& sndr, const Env& env) noexcept; |
| 135 | +</pre> |
| 136 | +<blockquote> |
| 137 | +<p> |
| 138 | +-14- <i>Effects</i>: Equivalent to: |
| 139 | +</p> |
| 140 | +<ol style="list-style-type: none"> |
| 141 | +<li><p>(14.1) — If <code><i>sender-for</i><Sndr, <del>continues_on_t</del><ins>schedule_from_t</ins>></code> is <code class='backtick'>true</code>, then</p> |
| 142 | +<blockquote><pre> |
| 143 | +return Domain(); |
| 144 | +</pre></blockquote> |
| 145 | +<p> |
| 146 | +where <code class='backtick'>Domain</code> is the type of the following expression: |
| 147 | +</p> |
| 148 | +<blockquote><pre> |
| 149 | +[] { |
| 150 | + auto [_, sch, _] = sndr; |
| 151 | + return <i>query-or-default</i>(get_domain, sch, default_domain()); |
| 152 | +}(); |
| 153 | +</pre></blockquote> |
| 154 | +<p> |
| 155 | +[<i>Note 1</i>: The <code><del>continues_on</del><ins>schedule_from</ins></code> algorithm |
| 156 | +works in tandem with <code><del>schedule_from</del><ins>continues_on</ins></code> |
| 157 | +(<del>33.9.12.5 <a href="https://wg21.link/exec.schedule.from">[exec.schedule.from]</a></del><ins>33.9.12.4 <a href="https://wg21.link/exec.continues.on">[exec.continues.on]</a></ins>) |
| 158 | +to give scheduler authors a way to customize both how to transition onto |
| 159 | +(<code><del>continues_on</del><ins>schedule_from</ins></code>) and off of |
| 160 | +(<code><del>schedule_from</del><ins>continues_on</ins></code>) a given execution context. |
| 161 | +Thus, <code><del>continues_on</del><ins>schedule_from</ins></code> ignores the domain of the |
| 162 | +predecessor and uses the domain of the destination scheduler to select a customization, |
| 163 | +a property that is unique to <code><del>continues_on</del><ins>schedule_from</ins></code>. |
| 164 | +That is why it is given special treatment here. — <i>end note</i>] |
| 165 | +</p> |
| 166 | +</li> |
| 167 | +<li><p>[…]</p></li> |
| 168 | +</ol> |
| 169 | +</blockquote> |
| 170 | +</blockquote> |
| 171 | + |
| 172 | +</li> |
| 173 | + |
| 174 | +</ol> |
| 175 | + |
| 176 | + |
| 177 | + |
| 178 | + |
| 179 | + |
| 180 | +</body> |
| 181 | +</html> |
0 commit comments