标准库标头 <hazard_pointer> (C++26)
来自cppreference.com
此头文件是线程支持库的一部分。
类 | ||
(C++26) | 允许对象具有风险保护的能力 (类模板) | |
(C++26) | 在任何时刻都只能被一个线程持有的单写多读指针 (类) | |
函数 | ||
(C++26) | 构造风险指针 (函数) | |
特化的 std::swap 算法 (函数模板) |
[编辑]概要
namespace std {// hazard_pointer_obj_basetemplate<class T, class D = default_delete<T>>class hazard_pointer_obj_base; // hazard_pointerclass hazard_pointer; // make_hazard_pointer hazard_pointer make_hazard_pointer();void swap(hazard_pointer&, hazard_pointer&)noexcept;}
[编辑]类模板 std::hazard_pointer_obj_base
namespace std {template<class T, class D = default_delete<T>>class hazard_pointer_obj_base {public:void retire(D d = D())noexcept;protected: hazard_pointer_obj_base()=default; hazard_pointer_obj_base(const hazard_pointer_obj_base&)=default; hazard_pointer_obj_base(hazard_pointer_obj_base&&)=default; hazard_pointer_obj_base& operator=(const hazard_pointer_obj_base&)=default; hazard_pointer_obj_base& operator=(hazard_pointer_obj_base&&)=default; ~hazard_pointer_obj_base()=default;private: D deleter;// 仅用于阐释};}
[编辑]类 std::hazard_pointer
namespace std {class hazard_pointer {public: hazard_pointer()noexcept; hazard_pointer(hazard_pointer&&)noexcept; hazard_pointer& operator=(hazard_pointer&&)noexcept; ~hazard_pointer(); bool empty()constnoexcept;template<class T> T* protect(const atomic<T*>& src)noexcept;template<class T>bool try_protect(T*& ptr, const atomic<T*>& src)noexcept;template<class T>void reset_protection(const T* ptr)noexcept;void reset_protection(nullptr_t = nullptr)noexcept;void swap(hazard_pointer&)noexcept;};}