std::atomic...::notify_one(3)

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

okay bestie, welcome to the std::atomic...::notify_one(3) page from the C++ Standard Libary manual set πŸ’– (yes, that spelling is the manual name β€” we're keeping it iconic and untouched). This one is all about std::atomic_ref::notify_one, and it's lowkey the β€œwake up at least one waiting bestie” button of the atomic world ✨

πŸŽ€ NAME πŸŽ€

  • std::atomic_ref::notify_one β€” std::atomic_ref::notify_one

πŸ¦‹ Synopsis πŸ¦‹

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

Both overloads are since C++20 πŸ‘‘. Overload (1) is const noexcept; overload (2) is const volatile noexcept β€” matching the code block exactly, no edits, periodt πŸ’….

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.

πŸ’œ Return value πŸ’œ

  • (none) β€” no return value, bestie. It does the notifying thing and vibes 🫢

✨ Notes ✨

This form of change-detection is often more efficient than simple polling or pure spinlocks. So if you were about to spin, the note is gently saying this change-detection form is often more efficient β€” that's the whole claim, no extra lore πŸ¦‹

🌸 Example 🌸

This section is incomplete. Reason: no example.

πŸ¦‹ See also πŸ¦‹

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

🏷️ Category 🏷️

  • * Todo no example

That's the page, bestie πŸ’… It came from http://cppreference.com with the 2024.06.10 date/version stamp, and the footer tag was std::atomic...::notify_one(3) β€” mwah, go notify at least one waiting thread and slay πŸŽ€πŸ”₯

πŸ“¦ where this page comes from