std::latch::count_down(3)

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

✨ NAME ✨

okay so welcome to the C++ Standard Libary manual, bestie β€” this is the page for std::latch::count_down. yes, the name is literally std::latch::count_down, and it’s giving β€œtiny counter go brrr” energy. πŸ’…

🌸 Synopsis 🌸

void count_down( std::ptrdiff_t n = 1 );  (since C++20)

okay so this icon atomically decrements the internal counter by n without blocking the caller. no waiting, no holding up the line, she just does the thing and keeps it moving. ✨

⚠️ bestie, listen: if n is greater than the value of the internal counter or is negative, the behavior is undefined. like πŸ’€ do not do that. undefined behavior is not the vibe.

and this part is important: this operation strongly happens-before all calls that are unblocked on this latch. iykyk β€” that ordering is the whole point. πŸ”₯

πŸŽ€ Parameters πŸŽ€

  • n β€” the value by which the internal counter is decreased. that’s it, that’s the parameter. πŸ’–

⭐ Return value ⭐

(none) β€” literally nothing comes back, she’s not giving you a return value. 🫢

πŸ’… Exceptions πŸ’…

Throws std::system_error with an error code allowed for mutex types on error. so yeah, if something goes sideways, that’s the exception situation. periodt. 😭


source: http://cppreference.com Β· date/version: 2024.06.10 β€” mwah, go forth and count down responsibly πŸ’œ

πŸ“¦ where this page comes from