71 template <
typename>
class Atom = std::atomic,
72 typename CountedDetail = detail::shared_ptr_internals>
74 using SharedPtr =
typename CountedDetail::template CountedPtr<T>;
75 using BasePtr =
typename CountedDetail::counted_base;
118 std::memory_order
order = std::memory_order_seq_cst) {
126 std::memory_order
order = std::memory_order_seq_cst) {
143 std::memory_order mo = std::memory_order_seq_cst)
noexcept {
150 std::memory_order success,
151 std::memory_order failure) {
156 if (!
owners_eq(oldptr, CountedDetail::get_counted_base(expected))) {
161 expectedptr = oldptr;
162 if (
ptr_.compare_exchange_weak(expectedptr, newptr, success, failure)) {
180 std::memory_order mo = std::memory_order_seq_cst)
noexcept {
187 std::memory_order success,
188 std::memory_order failure) {
194 std::memory_order mo = std::memory_order_seq_cst)
noexcept {
201 std::memory_order success,
202 std::memory_order failure) {
203 auto local_expected = expected;
208 }
while (local_expected == expected);
215 std::memory_order mo = std::memory_order_seq_cst)
noexcept {
222 std::memory_order success,
223 std::memory_order failure) {
248 CountedDetail::template release_shared<T>(res.
get(),
diff);
256 newval = CountedDetail::get_counted_base(n);
257 if (n.get() != CountedDetail::template get_shared_ptr<T>(newval)) {
260 auto data = CountedDetail::template make_ptr<SharedPtr>(n);
261 newval = CountedDetail::get_counted_base(
data);
271 newptr.
init(newval, count);
281 newval = CountedDetail::get_counted_base(n);
282 if (n.get() != CountedDetail::template get_shared_ptr<T>(newval)) {
285 auto data = CountedDetail::template make_ptr<SharedPtr>(
std::move(n));
286 newval = CountedDetail::get_counted_base(
data);
288 CountedDetail::release_ptr(
data);
291 CountedDetail::release_ptr(n);
297 newptr.
init(newval, count);
315 auto p1a = CountedDetail::template get_shared_ptr_from_counted_base<T>(
317 return CountedDetail::get_counted_base(p1a) == p2;
319 return p1.
get() == p2;
325 auto res = CountedDetail::template get_shared_ptr_from_counted_base<T>(
329 CountedDetail::template get_shared_ptr_from_counted_base<SharedPtr>(
344 local = ptr_.
load(std::memory_order_acquire);
355 local = ptr_.
load(std::memory_order_acquire);
368 CountedDetail::inc_shared_count(newlocal.
get(), batchcount);
379 if (local.
get() != p) {
382 auto newlocal =
local;
397 CountedDetail::template release_shared<T>(p,
count);
atomic_shared_ptr() noexcept
PackedPtr takeOwnedBase(std::memory_order order) const noexcept
void store(T v, std::memory_order mo=std::memory_order_seq_cst) noexcept
bool compare_exchange_strong(SharedPtr &expected, SharedPtr &&desired, std::memory_order success, std::memory_order failure)
void add_external(BasePtr *res, int64_t c=0) const
SharedPtr load(std::memory_order order=std::memory_order_seq_cst) const noexcept
void setExtra(uint16_t extra)
constexpr detail::Map< Move > move
bool compare_exchange_weak(SharedPtr &expected, SharedPtr &&desired, std::memory_order success, std::memory_order failure)
SharedPtr exchange(SharedPtr n, std::memory_order order=std::memory_order_seq_cst)
typename CountedDetail::counted_base BasePtr
unsigned int get_local_count(const PackedPtr &p) const
AtomicStruct< PackedPtr, Atom > ptr_
T load(std::memory_order mo=std::memory_order_seq_cst) const noexcept
—— Concurrent Priority Queue Implementation ——
requires E e noexcept(noexcept(s.error(std::move(e))))
bool compare_exchange_weak(SharedPtr &expected, const SharedPtr &n, std::memory_order success, std::memory_order failure)
void operator=(SharedPtr desired)
typename CountedDetail::template CountedPtr< T > SharedPtr
void init(T *initialPtr=nullptr, uint16_t initialExtra=0)
void putOwnedBase(BasePtr *p, unsigned int count, std::memory_order mo) const noexcept
std::memory_order default_failure_memory_order(std::memory_order successMode)
constexpr auto data(C &c) -> decltype(c.data())
atomic_shared_ptr(SharedPtr foo)
bool compare_exchange_strong(SharedPtr &expected, const SharedPtr &n, std::memory_order mo=std::memory_order_seq_cst) noexcept
bool compare_exchange_weak(SharedPtr &expected, const SharedPtr &n, std::memory_order mo=std::memory_order_seq_cst) noexcept
static constexpr unsigned ALIASED_PTR
SharedPtr get_shared_ptr(const PackedPtr &p, bool inc=true) const
bool owners_eq(PackedPtr &p1, BasePtr *p2)
static constexpr unsigned EXTERNAL_OFFSET
bool compare_exchange_weak(SharedPtr &expected, SharedPtr &&desired, std::memory_order mo=std::memory_order_seq_cst) noexcept
uint64_t diff(uint64_t a, uint64_t b)
bool compare_exchange_weak(T &v0, T v1, std::memory_order mo=std::memory_order_seq_cst) noexcept
bool is_lock_free() const noexcept
void store(SharedPtr n, std::memory_order order=std::memory_order_seq_cst)
void release_external(PackedPtr &res, int64_t c=0) const
bool compare_exchange_strong(SharedPtr &expected, SharedPtr &&desired, std::memory_order mo=std::memory_order_seq_cst) noexcept
bool compare_exchange_strong(SharedPtr &expected, const SharedPtr &n, std::memory_order success, std::memory_order failure)
PackedPtr get_newptr(SharedPtr &&n) const
PackedPtr get_newptr(const SharedPtr &n) const