std::condit...ariable_any(3)

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

πŸ‘‘ NAME πŸ‘‘

std::condition_variable_any::~condition_variable_any β€” the destructor for std::condition_variable_any, aka the goodbye function. This page is std::condit...ariable_any(3) from the C++ Standard Libary manual, and yes bestie the full name is also literally std::condition_variable_any::~condition_variable_any πŸ’…


πŸ’– Synopsis πŸ’–

~condition_variable_any();  (since C++11)

Destroys the object of type std::condition_variable_any. That's the whole mission, no cap. πŸ’–

Safety check, bestie: it is only safe to invoke the destructor if all threads have been notified. 🚨

It is not required that they have exited their respective wait functions: some threads may still be waiting to reacquire the associated lock, or may be waiting to be scheduled to run after reacquiring it. So like, notified does not automatically mean fully packed up and out the door. πŸ¦‹

The programmer must ensure that no threads attempt to wait on *this once the destructor has been started, especially when the waiting threads are calling the wait functions in a loop or are using the overloads of the wait functions that take a predicate. This is the part where you do not play games with the lifecycle, fr fr. 😭


πŸ¦‹ See also πŸ¦‹

C documentation for cnd_destroy β€” that's the C-side cousin, go say hi 🫢


mwah πŸ’‹ this page came from http://cppreference.com, version/date 2024.06.10, and the header stamped std::condit...ariable_any(3) β€” okay bye bestie, go destroy responsibly βœ¨πŸŽ€

πŸ“¦ where this page comes from