Skip to content
35 changes: 24 additions & 11 deletions source/threads.tex
Original file line number Diff line number Diff line change
Expand Up @@ -534,10 +534,10 @@
class stop_source;

// no-shared-stop-state indicator
struct nostopstate_t {
struct @\libglobal{nostopstate_t}@ {
explicit nostopstate_t() = default;
};
inline constexpr nostopstate_t nostopstate{};
inline constexpr nostopstate_t @\libglobal{nostopstate}@{};

// \ref{stopcallback}, class template \tcode{stop_callback}
template<class Callback>
Expand All @@ -557,7 +557,7 @@
class inplace_stop_callback;

template<class T, class CallbackFn>
using stop_callback_for_t = T::template callback_type<CallbackFn>;
using @\libglobal{stop_callback_for_t}@ = T::template callback_type<CallbackFn>;
}
\end{codeblock}

Expand Down Expand Up @@ -835,7 +835,7 @@
class stop_token {
public:
template<class CallbackFn>
using callback_type = stop_callback<CallbackFn>;
using @\libmember{callback_type}{stop_token}@ = stop_callback<CallbackFn>;

stop_token() noexcept = default;

Expand Down Expand Up @@ -1043,7 +1043,7 @@
template<class CallbackFn>
class stop_callback {
public:
using callback_type = CallbackFn;
using @\libmember{callback_type}{stop_callback}@ = CallbackFn;

// \ref{stopcallback.cons}, constructors and destructor
template<class Initializer>
Expand Down Expand Up @@ -1133,6 +1133,7 @@
It provides a stop token interface,
but also provides static information
that a stop is never possible nor requested.
\indexlibraryglobal{never_stop_token}%
\begin{codeblock}
namespace std {
class never_stop_token {
Expand All @@ -1141,10 +1142,10 @@
};
public:
template<class>
using callback_type = @\exposid{callback-type}@;
using @\libmember{callback_type}{never_stop_token}@ = @\exposid{callback-type}@;

static constexpr bool stop_requested() noexcept { return false; }
static constexpr bool stop_possible() noexcept { return false; }
static constexpr bool @\libmember{stop_requested}{never_stop_token}@() noexcept { return false; }
static constexpr bool @\libmember{stop_possible}{never_stop_token}@() noexcept { return false; }

bool operator==(const never_stop_token&) const = default;
};
Expand All @@ -1161,12 +1162,13 @@
It references the stop state of
its associated \tcode{inplace_stop_source} object\iref{stopsource.inplace},
if any.
\indexlibraryglobal{inplace_stop_token}%
\begin{codeblock}
namespace std {
class inplace_stop_token {
public:
template<class CallbackFn>
using callback_type = inplace_stop_callback<CallbackFn>;
using @\libmember{callback_type}{inplace_stop_token}@ = inplace_stop_callback<CallbackFn>;

inplace_stop_token() = default;
bool operator==(const inplace_stop_token&) const = default;
Expand All @@ -1184,6 +1186,7 @@

\rSec3[stoptoken.inplace.mem]{Member functions}

\indexlibrarymember{swap}{inplace_stop_token}%
\begin{itemdecl}
void swap(inplace_stop_token& rhs) noexcept;
\end{itemdecl}
Expand All @@ -1194,6 +1197,7 @@
Exchanges the values of \exposid{stop-source} and \tcode{rhs.\exposid{stop-source}}.
\end{itemdescr}

\indexlibrarymember{stop_requested}{inplace_stop_token}%
\begin{itemdecl}
bool stop_requested() const noexcept;
\end{itemdecl}
Expand All @@ -1215,6 +1219,7 @@
\end{note}
\end{itemdescr}

\indexlibrarymember{stop_possible}{inplace_stop_token}%
\begin{itemdecl}
stop_possible() const noexcept;
\end{itemdecl}
Expand All @@ -1241,6 +1246,7 @@
\pnum
The class \tcode{inplace_stop_source} models \exposconcept{stoppable-source}.

\indexlibraryglobal{inplace_stop_source}%
\begin{codeblock}
namespace std {
class inplace_stop_source {
Expand All @@ -1256,7 +1262,7 @@

// \ref{stopsource.inplace.mem}, stop handling
constexpr inplace_stop_token get_token() const noexcept;
static constexpr bool stop_possible() noexcept { return true; }
static constexpr bool @\libmember{stop_possible}{inplace_stop_source}@() noexcept { return true; }
bool stop_requested() const noexcept;
bool request_stop() noexcept;
};
Expand All @@ -1265,6 +1271,7 @@

\rSec3[stopsource.inplace.cons]{Constructors}

\indexlibraryctor{inplace_stop_source}%
\begin{itemdecl}
constexpr inplace_stop_source() noexcept;
\end{itemdecl}
Expand All @@ -1281,6 +1288,7 @@

\rSec3[stopsource.inplace.mem]{Member functions}

\indexlibrarymember{get_token}{inplace_stop_source}%
\begin{itemdecl}
constexpr inplace_stop_token get_token() const noexcept;
\end{itemdecl}
Expand All @@ -1292,6 +1300,7 @@
whose \exposid{stop-source} member is equal to \tcode{this}.
\end{itemdescr}

\indexlibrarymember{stop_requested}{inplace_stop_source}%
\begin{itemdecl}
bool stop_requested() const noexcept;
\end{itemdecl}
Expand All @@ -1303,6 +1312,7 @@
has received a stop request; otherwise, \tcode{false}.
\end{itemdescr}

\indexlibrarymember{request_stop}{inplace_stop_source}%
\begin{itemdecl}
bool request_stop() noexcept;
\end{itemdecl}
Expand All @@ -1321,12 +1331,13 @@

\rSec3[stopcallback.inplace.general]{General}

\indexlibraryglobal{inplace_stop_callback}%
\begin{codeblock}
namespace std {
template<class CallbackFn>
class inplace_stop_callback {
public:
using callback_type = CallbackFn;
using @\libmember{callback_type}{inplace_stop_callback}@ = CallbackFn;

// \ref{stopcallback.inplace.cons}, constructors and destructor
template<class Initializer>
Expand Down Expand Up @@ -1371,6 +1382,7 @@

\rSec3[stopcallback.inplace.cons]{Constructors and destructor}

\indexlibraryctor{inplace_stop_callback}%
\begin{itemdecl}
template<class Initializer>
explicit inplace_stop_callback(inplace_stop_token st, Initializer&& init)
Expand All @@ -1388,6 +1400,7 @@
and executes a stoppable callback registration\iref{stoptoken.concepts}.
\end{itemdescr}

\indexlibrarydtor{inplace_stop_callback}%
\begin{itemdecl}
~inplace_stop_callback();
\end{itemdecl}
Expand Down