Skip to content

Commit c373789

Browse files
jensmaurerzygoloid
authored andcommitted
P1643R1 Add wait/notify to atomic_ref<T>
1 parent 42f28d8 commit c373789

File tree

1 file changed

+87
-4
lines changed

1 file changed

+87
-4
lines changed

source/atomics.tex

Lines changed: 87 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -663,8 +663,9 @@
663663
\begin{itemize}
664664
\item \tcode{atomic<T>::wait},
665665
\item \tcode{atomic_flag::wait},
666-
\item \tcode{atomic_wait} and \tcode{atomic_wait_explicit}, and
667-
\item \tcode{atomic_flag_wait} and \tcode{atomic_flag_wait_explicit}.
666+
\item \tcode{atomic_wait} and \tcode{atomic_wait_explicit},
667+
\item \tcode{atomic_flag_wait} and \tcode{atomic_flag_wait_explicit}, and
668+
\item \tcode{atomic_ref<T>::wait}.
668669
\end{itemize}
669670
\end{note}
670671

@@ -674,8 +675,9 @@
674675
\begin{itemize}
675676
\item \tcode{atomic<T>::notify_one} and \tcode{atomic<T>::notify_all},
676677
\item \tcode{atomic_flag::notify_one} and \tcode{atomic_flag::notify_all},
677-
\item \tcode{atomic_notify_one} and \tcode{atomic_notify_all}, and
678-
\item \tcode{atomic_flag_notify_one} and \tcode{atomic_flag_notify_all}.
678+
\item \tcode{atomic_notify_one} and \tcode{atomic_notify_all},
679+
\item \tcode{atomic_flag_notify_one} and \tcode{atomic_flag_notify_all}, and
680+
\item \tcode{atomic_ref<T>::notify_one} and \tcode{atomic_ref<T>::notify_all}.
679681
\end{itemize}
680682
\end{note}
681683

@@ -724,6 +726,9 @@
724726
memory_order = memory_order_seq_cst) const noexcept;
725727
bool compare_exchange_strong(T&, T,
726728
memory_order = memory_order_seq_cst) const noexcept;
729+
void wait(T, memory_order = memory_order::seq_cst) const noexcept;
730+
void notify_one() noexcept;
731+
void notify_all() noexcept;
727732
};
728733
}
729734
\end{codeblock}
@@ -1017,6 +1022,72 @@
10171022
\end{note}
10181023
\end{itemdescr}
10191024

1025+
\indexlibrarymember{wait}{atomic_ref<T>}%
1026+
\begin{itemdecl}
1027+
void wait(T old, memory_order order = memory_order::seq_cst) const noexcept;
1028+
\end{itemdecl}
1029+
1030+
\begin{itemdescr}
1031+
\pnum
1032+
\expects
1033+
\tcode{order} is
1034+
neither \tcode{memory_order::release} nor \tcode{memory_order::acq_rel}.
1035+
1036+
\pnum
1037+
\effects
1038+
Repeatedly performs the following steps, in order:
1039+
\begin{itemize}
1040+
\item
1041+
Evaluates \tcode{load(order)} and
1042+
compares its value representation for equality against that of \tcode{old}.
1043+
\item
1044+
If they compare unequal, returns.
1045+
\item
1046+
Blocks until it
1047+
is unblocked by an atomic notifying operation or is unblocked spuriously.
1048+
\end{itemize}
1049+
1050+
\pnum
1051+
\remarks
1052+
This function is an atomic waiting operation\iref{atomics.wait}
1053+
on atomic object \tcode{*ptr}.
1054+
\end{itemdescr}
1055+
1056+
\indexlibrarymember{notify_one}{atomic_ref<T>}%
1057+
\begin{itemdecl}
1058+
void notify_one() noexcept;
1059+
\end{itemdecl}
1060+
1061+
\begin{itemdescr}
1062+
\pnum
1063+
\expects
1064+
Unblocks the execution of at least one atomic waiting operation on \tcode{*ptr}
1065+
that is eligible to be unblocked\iref{atomics.wait} by this call,
1066+
if any such atomic waiting operations exist.
1067+
1068+
\pnum
1069+
\remarks
1070+
This function is an atomic notifying operation\iref{atomics.wait}
1071+
on atomic object \tcode{*ptr}.
1072+
\end{itemdescr}
1073+
1074+
\indexlibrarymember{notify_all}{atomic_ref<T>}%
1075+
\begin{itemdecl}
1076+
void notify_all() noexcept;
1077+
\end{itemdecl}
1078+
1079+
\begin{itemdescr}
1080+
\pnum
1081+
\expects
1082+
Unblocks the execution of all atomic waiting operations on \tcode{*ptr}
1083+
that are eligible to be unblocked\iref{atomics.wait} by this call.
1084+
1085+
\pnum
1086+
\remarks
1087+
This function is an atomic notifying operation\iref{atomics.wait}
1088+
on atomic object \tcode{*ptr}.
1089+
\end{itemdescr}
1090+
10201091
\rSec2[atomics.ref.int]{Specializations for integral types}
10211092

10221093
\pnum
@@ -1079,6 +1150,10 @@
10791150
bool compare_exchange_strong(@\placeholder{integral}@&, @\placeholder{integral}@,
10801151
memory_order = memory_order_seq_cst) const noexcept;
10811152

1153+
void wait(integral, memory_order = memory_order::seq_cst) const noexcept;
1154+
void notify_one() noexcept;
1155+
void notify_all() noexcept;
1156+
10821157
@\placeholdernc{integral}@ fetch_add(@\placeholdernc{integral}@,
10831158
memory_order = memory_order_seq_cst) const noexcept;
10841159
@\placeholdernc{integral}@ fetch_sub(@\placeholdernc{integral}@,
@@ -1206,6 +1281,10 @@
12061281
bool compare_exchange_strong(@\placeholder{floating-point}@&, @\placeholder{floating-point}@,
12071282
memory_order = memory_order_seq_cst) const noexcept;
12081283

1284+
void wait(@\placeholdernc{floating-point}@, memory_order = memory_order::seq_cst) const noexcept;
1285+
void notify_one() noexcept;
1286+
void notify_all() noexcept;
1287+
12091288
@\placeholder{floating-point}@ fetch_add(@\placeholder{floating-point}@,
12101289
memory_order = memory_order_seq_cst) const noexcept;
12111290
@\placeholder{floating-point}@ fetch_sub(@\placeholder{floating-point}@,
@@ -1303,6 +1382,10 @@
13031382
bool compare_exchange_strong(T*&, T*,
13041383
memory_order = memory_order_seq_cst) const noexcept;
13051384

1385+
void wait(T*, memory_order = memory_order::seq_cst) const noexcept;
1386+
void notify_one() noexcept;
1387+
void notify_all() noexcept;
1388+
13061389
T* fetch_add(difference_type, memory_order = memory_order_seq_cst) const noexcept;
13071390
T* fetch_sub(difference_type, memory_order = memory_order_seq_cst) const noexcept;
13081391

0 commit comments

Comments
 (0)