30 #ifndef _SHARED_PTR_ATOMIC_H 31 #define _SHARED_PTR_ATOMIC_H 1 35 namespace std _GLIBCXX_VISIBILITY(default)
37 _GLIBCXX_BEGIN_NAMESPACE_VERSION
46 _Sp_locker(
const _Sp_locker&) =
delete;
47 _Sp_locker& operator=(
const _Sp_locker&) =
delete;
51 _Sp_locker(
const void*) noexcept;
52 _Sp_locker(const
void*, const
void*) noexcept;
56 unsigned char _M_key1;
57 unsigned char _M_key2;
59 explicit _Sp_locker(
const void*,
const void* =
nullptr) { }
69 template<
typename _Tp, _Lock_policy _Lp>
71 atomic_is_lock_free(
const __shared_ptr<_Tp, _Lp>* __p)
74 return __gthread_active_p() == 0;
80 template<
typename _Tp>
83 {
return std::atomic_is_lock_free<_Tp, __default_lock_policy>(__p); }
96 template<
typename _Tp>
100 _Sp_locker __lock{__p};
104 template<
typename _Tp>
109 template<
typename _Tp, _Lock_policy _Lp>
110 inline __shared_ptr<_Tp, _Lp>
113 _Sp_locker __lock{__p};
117 template<
typename _Tp, _Lock_policy _Lp>
118 inline __shared_ptr<_Tp, _Lp>
119 atomic_load(
const __shared_ptr<_Tp, _Lp>* __p)
132 template<
typename _Tp>
137 _Sp_locker __lock{__p};
141 template<
typename _Tp>
146 template<
typename _Tp, _Lock_policy _Lp>
148 atomic_store_explicit(__shared_ptr<_Tp, _Lp>* __p,
149 __shared_ptr<_Tp, _Lp> __r,
152 _Sp_locker __lock{__p};
156 template<
typename _Tp, _Lock_policy _Lp>
158 atomic_store(__shared_ptr<_Tp, _Lp>* __p, __shared_ptr<_Tp, _Lp> __r)
169 template<
typename _Tp>
174 _Sp_locker __lock{__p};
179 template<
typename _Tp>
184 memory_order_seq_cst);
187 template<
typename _Tp, _Lock_policy _Lp>
188 inline __shared_ptr<_Tp, _Lp>
189 atomic_exchange_explicit(__shared_ptr<_Tp, _Lp>* __p,
190 __shared_ptr<_Tp, _Lp> __r,
193 _Sp_locker __lock{__p};
198 template<
typename _Tp, _Lock_policy _Lp>
199 inline __shared_ptr<_Tp, _Lp>
200 atomic_exchange(__shared_ptr<_Tp, _Lp>* __p, __shared_ptr<_Tp, _Lp> __r)
203 memory_order_seq_cst);
218 template<
typename _Tp>
227 _Sp_locker __lock{__p, __v};
229 if (*__p == *__v && !__less(*__p, *__v) && !__less(*__v, *__p))
231 __x = std::move(*__p);
232 *__p = std::move(__w);
235 __x = std::move(*__v);
240 template<
typename _Tp>
246 std::move(__w), memory_order_seq_cst, memory_order_seq_cst);
249 template<
typename _Tp>
258 std::move(__w), __success, __failure);
261 template<
typename _Tp>
267 std::move(__w), memory_order_seq_cst, memory_order_seq_cst);
270 template<
typename _Tp, _Lock_policy _Lp>
272 atomic_compare_exchange_strong_explicit(__shared_ptr<_Tp, _Lp>* __p,
273 __shared_ptr<_Tp, _Lp>* __v,
274 __shared_ptr<_Tp, _Lp> __w,
278 __shared_ptr<_Tp, _Lp> __x;
279 _Sp_locker __lock{__p, __v};
281 if (*__p == *__v && !__less(*__p, *__v) && !__less(*__v, *__p))
283 __x = std::move(*__p);
284 *__p = std::move(__w);
287 __x = std::move(*__v);
292 template<
typename _Tp, _Lock_policy _Lp>
294 atomic_compare_exchange_strong(__shared_ptr<_Tp, _Lp>* __p,
295 __shared_ptr<_Tp, _Lp>* __v,
296 __shared_ptr<_Tp, _Lp> __w)
299 std::move(__w), memory_order_seq_cst, memory_order_seq_cst);
302 template<
typename _Tp, _Lock_policy _Lp>
304 atomic_compare_exchange_weak_explicit(__shared_ptr<_Tp, _Lp>* __p,
305 __shared_ptr<_Tp, _Lp>* __v,
306 __shared_ptr<_Tp, _Lp> __w,
311 std::move(__w), __success, __failure);
314 template<
typename _Tp, _Lock_policy _Lp>
316 atomic_compare_exchange_weak(__shared_ptr<_Tp, _Lp>* __p,
317 __shared_ptr<_Tp, _Lp>* __v,
318 __shared_ptr<_Tp, _Lp> __w)
321 std::move(__w), memory_order_seq_cst, memory_order_seq_cst);
327 _GLIBCXX_END_NAMESPACE_VERSION
330 #endif // _SHARED_PTR_ATOMIC_H __shared_ptr< _Tp, _Lp > atomic_exchange_explicit(__shared_ptr< _Tp, _Lp > *__p, __shared_ptr< _Tp, _Lp > __r, memory_order)
Atomic exchange for shared_ptr objects.
void atomic_store_explicit(__shared_ptr< _Tp, _Lp > *__p, __shared_ptr< _Tp, _Lp > __r, memory_order)
Atomic store for shared_ptr objects.
__shared_ptr< _Tp, _Lp > atomic_load_explicit(const __shared_ptr< _Tp, _Lp > *__p, memory_order)
Atomic load for shared_ptr objects.
memory_order
Enumeration for memory_order.
A smart pointer with reference-counted copy semantics.
bool atomic_compare_exchange_strong_explicit(__shared_ptr< _Tp, _Lp > *__p, __shared_ptr< _Tp, _Lp > *__v, __shared_ptr< _Tp, _Lp > __w, memory_order, memory_order)
Atomic compare-and-swap for shared_ptr objects.
Primary template owner_less.
bool atomic_compare_exchange_weak_explicit(__shared_ptr< _Tp, _Lp > *__p, __shared_ptr< _Tp, _Lp > *__v, __shared_ptr< _Tp, _Lp > __w, memory_order __success, memory_order __failure)
Atomic compare-and-swap for shared_ptr objects.
ISO C++ entities toplevel namespace is std.