Skip to content

Commit 9a441b8

Browse files
jensmaurerzygoloid
authored andcommitted
P1644R0 Add wait/notify to atomic<shared_ptr<T>>
1 parent c373789 commit 9a441b8

File tree

1 file changed

+137
-0
lines changed

1 file changed

+137
-0
lines changed

source/utilities.tex

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11737,6 +11737,10 @@
1173711737
bool compare_exchange_strong(shared_ptr<T>& expected, shared_ptr<T> desired,
1173811738
memory_order order = memory_order::seq_cst) noexcept;
1173911739

11740+
void wait(shared_ptr<T> old, memory_order order = memory_order::seq_cst) const noexcept;
11741+
void notify_one() noexcept;
11742+
void notify_all() noexcept;
11743+
1174011744
constexpr atomic() noexcept = default;
1174111745
atomic(shared_ptr<T> desired) noexcept;
1174211746
atomic(const atomic&) = delete;
@@ -11951,6 +11955,70 @@
1195111955
shall be replaced by the value \tcode{memory_order::relaxed}.
1195211956
\end{itemdescr}
1195311957

11958+
\indexlibrarymember{wait}{atomic<shared_ptr<T>>}%
11959+
\begin{itemdecl}
11960+
void wait(shared_ptr<T> old, memory_order order = memory_order::seq_cst) const noexcept;
11961+
\end{itemdecl}
11962+
11963+
\begin{itemdescr}
11964+
\pnum
11965+
\expects
11966+
\tcode{order} is
11967+
neither \tcode{memory_order::release} nor \tcode{memory_order::acq_rel}.
11968+
11969+
\pnum
11970+
\effects
11971+
Repeatedly performs the following steps, in order:
11972+
\begin{itemize}
11973+
\item
11974+
Evaluates \tcode{load(order)} and compares it to \tcode{old}.
11975+
\item
11976+
If the two are not equivalent, returns.
11977+
\item
11978+
Blocks until it
11979+
is unblocked by an atomic notifying operation or is unblocked spuriously.
11980+
\end{itemize}
11981+
11982+
\pnum
11983+
\remarks
11984+
Two \tcode{shared_ptr} objects are equivalent
11985+
if they store the same pointer and either share ownership or are both empty.
11986+
This function is an atomic waiting operation\iref{atomics.wait}.
11987+
\end{itemdescr}
11988+
11989+
\indexlibrarymember{notify_one}{atomic<shared_ptr<T>>}%
11990+
\begin{itemdecl}
11991+
void notify_one() noexcept;
11992+
\end{itemdecl}
11993+
11994+
\begin{itemdescr}
11995+
\pnum
11996+
\effects
11997+
Unblocks the execution of at least one atomic waiting operation
11998+
that is eligible to be unblocked\iref{atomics.wait} by this call,
11999+
if any such atomic waiting operations exist.
12000+
12001+
\pnum
12002+
\remarks
12003+
This function is an atomic notifying operation\iref{atomics.wait}.
12004+
\end{itemdescr}
12005+
12006+
\indexlibrarymember{notify_all}{atomic<shared_ptr<T>>}%
12007+
\begin{itemdecl}
12008+
void notify_all() noexcept;
12009+
\end{itemdecl}
12010+
12011+
\begin{itemdescr}
12012+
\pnum
12013+
\effects
12014+
Unblocks the execution of all atomic waiting operations
12015+
that are eligible to be unblocked\iref{atomics.wait} by this call.
12016+
12017+
\pnum
12018+
\remarks
12019+
This function is an atomic notifying operation\iref{atomics.wait}.
12020+
\end{itemdescr}
12021+
1195412022
\rSec3[util.smartptr.atomic.weak]{Atomic specialization for \tcode{weak_ptr}}
1195512023
\indexlibrary{\idxcode{atomic<weak_ptr<T>>}}%
1195612024
\begin{codeblock}
@@ -11977,6 +12045,10 @@
1197712045
bool compare_exchange_strong(weak_ptr<T>& expected, weak_ptr<T> desired,
1197812046
memory_order order = memory_order::seq_cst) noexcept;
1197912047

12048+
void wait(weak_ptr<T> old, memory_order order = memory_order::seq_cst) const noexcept;
12049+
void notify_one() noexcept;
12050+
void notify_all() noexcept;
12051+
1198012052
constexpr atomic() noexcept = default;
1198112053
atomic(weak_ptr<T> desired) noexcept;
1198212054
atomic(const atomic&) = delete;
@@ -12189,6 +12261,71 @@
1218912261
a value of \tcode{memory_order::release}
1219012262
shall be replaced by the value \tcode{memory_order::relaxed}.
1219112263
\end{itemdescr}
12264+
12265+
\indexlibrarymember{wait}{atomic<weak_ptr<T>>}%
12266+
\begin{itemdecl}
12267+
void wait(weak_ptr<T> old, memory_order order = memory_order::seq_cst) const noexcept;
12268+
\end{itemdecl}
12269+
12270+
\begin{itemdescr}
12271+
\pnum
12272+
\expects
12273+
\tcode{order} is
12274+
neither \tcode{memory_order::release} nor \tcode{memory_order::acq_rel}.
12275+
12276+
\pnum
12277+
\effects
12278+
Repeatedly performs the following steps, in order:
12279+
\begin{itemize}
12280+
\item
12281+
Evaluates \tcode{load(order)} and compares it to \tcode{old}.
12282+
\item
12283+
If the two are not equivalent, returns.
12284+
\item
12285+
Blocks until it
12286+
is unblocked by an atomic notifying operation or is unblocked spuriously.
12287+
\end{itemize}
12288+
12289+
\pnum
12290+
\remarks
12291+
Two \tcode{weak_ptr} objects are equivalent
12292+
if they store the same pointer and either share ownership or are both empty.
12293+
This function is an atomic waiting operation\iref{atomics.wait}.
12294+
\end{itemdescr}
12295+
12296+
12297+
\indexlibrarymember{notify_one}{atomic<weak_ptr<T>>}%
12298+
\begin{itemdecl}
12299+
void notify_one() noexcept;
12300+
\end{itemdecl}
12301+
12302+
\begin{itemdescr}
12303+
\pnum
12304+
\effects
12305+
Unblocks the execution of at least one atomic waiting operation
12306+
that is eligible to be unblocked\iref{atomics.wait} by this call,
12307+
if any such atomic waiting operations exist.
12308+
12309+
\pnum
12310+
\remarks
12311+
This function is an atomic notifying operation\iref{atomics.wait}.
12312+
\end{itemdescr}
12313+
12314+
\indexlibrarymember{notify_all}{atomic<weak_ptr<T>>}%
12315+
\begin{itemdecl}
12316+
void notify_all() noexcept;
12317+
\end{itemdecl}
12318+
12319+
\begin{itemdescr}
12320+
\pnum
12321+
\effects
12322+
Unblocks the execution of all atomic waiting operations
12323+
that are eligible to be unblocked\iref{atomics.wait} by this call.
12324+
12325+
\pnum
12326+
\remarks
12327+
This function is an atomic notifying operation\iref{atomics.wait}.
12328+
\end{itemdescr}
1219212329
\indextext{atomic smart pointers|)}
1219312330

1219412331
\rSec1[mem.res]{Memory resources}

0 commit comments

Comments
 (0)