std::atomic_flag::wait(3)
π¦ std::atomic_flag::wait(3) π¦
okay so bestie, welcome to the C++ Standard Libary manual page for std::atomic_flag::wait β yes, the manual name is folded right in here, and the group chat is open. π
β¨
πΈ NAME πΈ
std::atomic_flag::wait - std::atomic_flag::wait
literally the name is the same thing twice, and that's iconic. periodt. π
β¨ Synopsis β¨
void wait( bool old, std::memory_order order =
std::memory_order::seq_cst ) const
(1) (since C++20)
noexcept;
void wait( bool old, std::memory_order order =
std::memory_order::seq_cst ) const
(2) (since C++20)
volatile noexcept;
bestie, these are atomic waiting operations π and the vibe is: it behaves as if it repeatedly does this little loop:
- Compare
this->test(order)with that ofold.- If those are equal, then blocks until
*thisis notified bynotify_one()ornotify_all(), or the thread is unblocked spuriously. - Otherwise, returns.
- If those are equal, then blocks until
no cap: these functions are guaranteed to return only if value has changed, even if the underlying implementation unblocks spuriously. π«Ά
π¨ okay bestie, important: iforderis one ofstd::memory_order::releaseandstd::memory_order::acq_rel, the behavior is undefined. not cute, not safe, undefined. π
π Parameters π
oldβ the value to check theatomic_flag's object no longer contains.orderβ memory order constraints to enforce.
π Return value π
(none) β literally none, bestie. π
π§ Notes π§
this form of change-detection is often more efficient than simple polling or pure spinlocks. β¨
due to the ABA problem, transient changes from old to another value and back to old might be missed, and not unblock. π that's the tea.
π Example π
so the Example section is literally incomplete bestie:
This section is incomplete Reason: no example
π₯ See also π₯
notify_oneβ notifies at least one thread waiting on the atomic object. (C++20) (public member function)notify_allβ notifies all threads blocked waiting on the atomic object. (C++20) (public member function)atomic_flag_notify_oneβ notifies a thread blocked inatomic_flag_wait. (C++20) (function)atomic_flag_notify_allβ notifies all threads blocked inatomic_flag_wait. (C++20) (function)
π Category π
- Todo no example β category tag:
* Todo no example. slay, but also π.
mwah π β this page came from http://cppreference.com, version/date 2024.06.10, and it's std::atomic_flag::wait(3). that's the footer tea, periodt. π«Άπ
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms