std::atomic::notify_one(3)

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

🌟 std::atomic::notify_one(3) 🌟

okay so this is the std::atomic::notify_one(3) page from the C++ Standard Libary manual β€” yes, Libary is literally the manual name here, no cap. We're doing C++20 atomic notify-one vibes, and every single detail is staying. periodt. πŸ’…

🌸 NAME 🌸

  • std::atomic::notify_one - std::atomic::notify_one

✨ Synopsis ✨

okay so there are two overloads, both noexcept, both since C++20:

void notify_one() noexcept;          (1) (since C++20)
void notify_one() volatile noexcept; (2) (since C++20)

Performs atomic notifying operations. If there is a thread blocked in atomic waiting operation (i.e. wait()) on *this, then unblocks at least one such thread; otherwise does nothing. That's the whole move, bestie. ✨

πŸ’– Return value πŸ’–

  • (none) β€” literally nothing comes back. The return value is (none), and that's iconic. πŸ’–

🧠 Notes 🧠

This form of change-detection is often more efficient than simple polling or pure spinlocks. That's the note, and honestly slay for efficiency. πŸ”₯

πŸ₯Ί Example πŸ₯Ί

Not me checking the example section and it's literally:

  • This section is incomplete
  • Reason: no example

😭 no example yet, bestie. We move. 🫢

πŸ‘€ See also πŸ‘€

the page lists these exactly, including the standalone (C++20) line, so don't come for me:

  • wait β€” blocks the thread until notified and the atomic value changes. (C++20) β€” (public member function)
  • atomic_wait
  • atomic_wait_explicit β€” blocks the thread until notified and the atomic value changes. (C++20) β€” (function template)
  • (C++20)
  • atomic_notify_one β€” notifies a thread blocked in atomic_wait. (C++20) β€” (function template)

πŸŽ€ Category πŸŽ€

  • * Todo no example

source/version + date sign-off: http://cppreference.com Β· 2024.06.10 Β· std::atomic::notify_one(3) β€” okay bye bestie, go be the notify_one you are and slay πŸ’…πŸ’–

πŸ“¦ where this page comes from