Skip to content

Commit 12ae227

Browse files
committed
P3284R4 write_env and unstoppable Sender Adaptors
1 parent 2e12f5e commit 12ae227

File tree

1 file changed

+66
-53
lines changed

1 file changed

+66
-53
lines changed

source/exec.tex

Lines changed: 66 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,8 @@
636636
struct @\libglobal{stopped_as_optional_t}@ { @\unspec@ };
637637
struct @\libglobal{stopped_as_error_t}@ { @\unspec@ };
638638

639+
inline constexpr @\unspec@ @\libglobal{write_env}@{};
640+
inline constexpr @\unspec@ @\libglobal{unstoppable}@{};
639641
inline constexpr starts_on_t @\libglobal{starts_on}@{};
640642
inline constexpr continues_on_t @\libglobal{continues_on}@{};
641643
inline constexpr on_t @\libglobal{on}@{};
@@ -1865,57 +1867,6 @@
18651867
denoted by \tcode{\exposid{completion-signatures-for}<Sndr, Env>}
18661868
to communicate to users why.
18671869

1868-
\begin{itemdecl}
1869-
template<@\libconcept{sender}@ Sndr, @\exposconcept{queryable}@ Env>
1870-
constexpr auto @\exposid{write-env}@(Sndr&& sndr, Env&& env); // \expos
1871-
\end{itemdecl}
1872-
1873-
\begin{itemdescr}
1874-
\pnum
1875-
\exposid{write-env} is an exposition-only sender adaptor that,
1876-
when connected with a receiver \tcode{rcvr},
1877-
connects the adapted sender with a receiver
1878-
whose execution environment is the result of
1879-
joining the \exposconcept{queryable} argument \tcode{env}
1880-
to the result of \tcode{get_env(rcvr)}.
1881-
1882-
\pnum
1883-
Let \exposid{write-env-t} be an exposition-only empty class type.
1884-
1885-
\pnum
1886-
\returns
1887-
\begin{codeblock}
1888-
@\exposid{make-sender}@(@\exposid{write-env-t}@(), std::forward<Env>(env), std::forward<Sndr>(sndr))
1889-
\end{codeblock}
1890-
1891-
\pnum
1892-
\remarks
1893-
The exposition-only class template \exposid{impls-for}\iref{exec.snd.general}
1894-
is specialized for \exposid{write-env-t} as follows:
1895-
\begin{codeblock}
1896-
template<>
1897-
struct @\exposid{impls-for}@<@\exposid{write-env-t}@> : @\exposid{default-impls}@ {
1898-
static constexpr auto @\exposid{get-env}@ =
1899-
[](auto, const auto& state, const auto& rcvr) noexcept {
1900-
return @\seebelow@;
1901-
};
1902-
};
1903-
\end{codeblock}
1904-
Invocation of
1905-
\tcode{\exposid{impls-for}<\exposid{write-env-t}>::\exposid{get-env}}
1906-
returns an object \tcode{e} such that
1907-
\begin{itemize}
1908-
\item
1909-
\tcode{decltype(e)} models \exposconcept{queryable} and
1910-
\item
1911-
given a query object \tcode{q},
1912-
the expression \tcode{e.query(q)} is expression-equivalent
1913-
to \tcode{state.query(q)} if that expression is valid,
1914-
otherwise, \tcode{e.query(q)} is expression-equivalent
1915-
to \tcode{get_env(rcvr).que\-ry(q)}.
1916-
\end{itemize}
1917-
\end{itemdescr}
1918-
19191870
\rSec2[exec.snd.concepts]{Sender concepts}
19201871

19211872
\pnum
@@ -2803,6 +2754,68 @@
28032754
the initializations of the bound argument entities of the result,
28042755
as specified above, are all well-formed.
28052756

2757+
\rSec3[exec.write.env]{\tcode{execution::write_env}}
2758+
2759+
\pnum
2760+
\tcode{write_env} is a sender adaptor
2761+
that accepts a sender and a queryable object, and
2762+
that returns a sender that,
2763+
when connected with a receiver \tcode{rcvr},
2764+
connects the adapted sender with a receiver
2765+
whose execution environment is the result of
2766+
joining the \exposconcept{queryable} object
2767+
to the result of \tcode{get_env(rcvr)}.
2768+
2769+
\pnum
2770+
\tcode{write_env} is a customization point object.
2771+
For some subexpressions \tcode{sndr} and \tcode{env},
2772+
if \tcode{decltype((sndr))} does not satisfy \libconcept{sender} or
2773+
if \tcode{decltype((env))} does not satisfy \exposconcept{queryable},
2774+
the expression \tcode{write_env(sndr, env)} is ill-formed.
2775+
Otherwise, it is expression-equivalent to
2776+
\tcode{\exposid{make-sender}(write_env, env, sndr)}.
2777+
2778+
\pnum
2779+
Let \exposid{write-env-t} denote the type \tcode{decltype(auto(write_env))}.
2780+
The exposition-only class template \exposid{impls-for}\iref{exec.snd.general}
2781+
is specialized for \exposid{write-env-t} as follows:
2782+
\begin{codeblock}
2783+
template<>
2784+
struct @\exposid{impls-for}@<@\exposid{write-env-t}@> : @\exposid{default-impls}@ {
2785+
static constexpr auto @\exposid{get-env}@ =
2786+
[](auto, const auto& state, const auto& rcvr) noexcept {
2787+
return @\seebelow@;
2788+
};
2789+
};
2790+
\end{codeblock}
2791+
Invocation of
2792+
\tcode{\exposid{impls-for}<\exposid{write-env-t}>::\exposid{get-env}}
2793+
returns an object \tcode{e} such that
2794+
\begin{itemize}
2795+
\item
2796+
\tcode{decltype(e)} models \exposconcept{queryable} and
2797+
\item
2798+
given a query object \tcode{q},
2799+
the expression \tcode{e.query(q)} is expression-equivalent
2800+
to \tcode{state.query(q)} if that expression is valid,
2801+
otherwise, \tcode{e.query(q)} is expression-equivalent
2802+
to \tcode{get_env(rcvr).que\-ry(q)}.
2803+
\end{itemize}
2804+
2805+
\rSec3[exec.unstoppable]{\tcode{execution::unstoppable}}
2806+
2807+
\pnum
2808+
\tcode{unstoppable} is a sender adaptor
2809+
that connects its inner sender
2810+
with a receiver that has the execution environment of the outer receiver
2811+
but with an object of type \tcode{never_stop_token}
2812+
as the result of the \tcode{get_stop_token query}.
2813+
2814+
\pnum
2815+
For a subexpression \tcode{sndr},
2816+
\tcode{unstoppable(sndr)} is expression-equivalent to
2817+
\tcode{write_env(sndr, prop(get_stop_token, never_stop_token\{\}))}.
2818+
28062819
\rSec3[exec.starts.on]{\tcode{execution::starts_on}}
28072820

28082821
\pnum
@@ -3243,11 +3256,11 @@
32433256
if constexpr (@\libconcept{same_as}@<decltype(orig_sch), @\exposid{not-a-scheduler}@>) {
32443257
return @\exposid{not-a-sender}@{};
32453258
} else {
3246-
return @\exposid{write-env}@(
3259+
return write_env(
32473260
continues_on(
32483261
std::forward_like<OutSndr>(closure)(
32493262
continues_on(
3250-
@\exposid{write-env}@(std::forward_like<OutSndr>(child), @\exposid{SCHED-ENV}@(orig_sch)),
3263+
write_env(std::forward_like<OutSndr>(child), @\exposid{SCHED-ENV}@(orig_sch)),
32513264
sch)),
32523265
orig_sch),
32533266
@\exposid{SCHED-ENV}@(sch));

0 commit comments

Comments
 (0)