std::experi..._shared_ptr(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

πŸ’… NAME

std::experimental::atomic_shared_ptr β€” bestie, that's literally the whole name, it's std::experimental::atomic_shared_ptr πŸ’–

Okay so real talk, this is the manual page for it, from the C++ Standard Library, and we're gonna get into it ✨


✨ SYNOPSIS

First things first, where does it live? It's defined in header <experimental/atomic> πŸŽ€

template< class T >                      (concurrency TS)
class atomic_shared_ptr;

So the class template atomic_shared_ptr gives you thread-safe atomic pointer operations over a std::shared_ptr. No cap. And the glow-up here? It's a better alternative to the non-member shared_ptr atomic access functions πŸ¦‹ like, genuinely, she ate πŸ’…


🌸 MEMBER FUNCTIONS

Here's the whole cast of characters, and yes they're all public member functions πŸ‘‘

  • constructor β€” constructs an atomic_shared_ptr object ✨
  • operator= β€” stores a value into an atomic_shared_ptr object πŸŽ€
  • is_lock_free β€” checks if the atomic_shared_ptr object is lock-free πŸ¦‹
  • store β€” atomically replaces the value of the atomic object with a non-atomic argument πŸ’–
  • load β€” atomically obtains the value of the atomic object ⭐
  • operator shared_ptr<T> β€” loads a value from an atomic object 🌈
  • exchange β€” atomically replaces the value of the atomic object and obtains the value held previously πŸ”₯
  • compare_exchange_weak / compare_exchange_strong β€” atomically compares the value of the atomic object with a non-atomic argument and performs atomic exchange if equal, or atomic load if not πŸ‘‘ (yes those two are listed together, they're a package deal, iykyk)

No notes, she's iconic, go be thread-safe about it 🫢

πŸ’Œ source: cppreference.com, version 2024.06.10, and the original was std::experi..._shared_ptr(3) from the C++ Standard Libary β€” mwah, bye bestie πŸ’‹

πŸ“¦ where this page comes from