From 0cdf18c3af10a2dcfda3d029649574172889d6bd Mon Sep 17 00:00:00 2001 From: Eisenwave Date: Sun, 14 Jun 2026 14:03:10 +0200 Subject: [PATCH] P3428R4 Hazard Pointer Batches --- source/support.tex | 2 +- source/threads.tex | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/source/support.tex b/source/support.tex index 70028e6719..156d06dbe9 100644 --- a/source/support.tex +++ b/source/support.tex @@ -719,7 +719,7 @@ // also in \libheader{unordered_map}, \libheader{unordered_set} #define @\defnlibxname{cpp_lib_hardware_interference_size}@ 201703L // freestanding, also in \libheader{new} #define @\defnlibxname{cpp_lib_has_unique_object_representations}@ 201606L // freestanding, also in \libheader{type_traits} -#define @\defnlibxname{cpp_lib_hazard_pointer}@ 202306L // also in \libheader{hazard_pointer} +#define @\defnlibxname{cpp_lib_hazard_pointer}@ 202606L // also in \libheader{hazard_pointer} #define @\defnlibxname{cpp_lib_hive}@ 202502L // also in \libheader{hive} #define @\defnlibxname{cpp_lib_hypot}@ 201603L // also in \libheader{cmath} #define @\defnlibxname{cpp_lib_incomplete_container_elements}@ 201505L diff --git a/source/threads.tex b/source/threads.tex index b3a041cf6f..60b0630438 100644 --- a/source/threads.tex +++ b/source/threads.tex @@ -13415,6 +13415,8 @@ // \ref{saferecl.hp.holder.nonmem}, non-member functions hazard_pointer make_hazard_pointer(); void swap(hazard_pointer&, hazard_pointer&) noexcept; + void make_hazard_pointer_batch(span); + void clear_hazard_pointer_batch(span) noexcept; } \end{codeblock} @@ -13741,3 +13743,37 @@ \effects Equivalent to \tcode{a.swap(b)}. \end{itemdescr} + +\indexlibrarymember{make_hazard_pointer_batch}{hazard_pointer}% +\begin{itemdecl} +void make_hazard_pointer_batch(span batch); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +If an exception is thrown, there are no effects. +Otherwise, for each element \tcode{e} of \tcode{batch} +such that \tcode{e.empty()} is \tcode{true}, +constructs a hazard pointer and makes \tcode{e} +the owner of that hazard pointer. + +\pnum +\throws +\tcode{bad_alloc} if memory for any of the newly-constructed hazard pointers +could not be allocated. +\end{itemdescr} + +\indexlibrarymember{clear_hazard_pointer_batch}{hazard_pointer}% +\begin{itemdecl} +void clear_hazard_pointer_batch(span batch) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +For each element \tcode{e} of \tcode{batch}, +if \tcode{e.empty()} is \tcode{false}, +destroys the hazard pointer owned by \tcode{e} and +makes \tcode{e} empty. +\end{itemdescr}