std::counti...re::release(3)

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

✨ NAME ✨

Okay so bestie, this is std::counting_semaphore::release(3) β€” header vibe: std::counti...re::release(3) β€” from the C++ Standard Libary manual (yes, that spelling is literally in the source, not me πŸ’€).

The name is std::counting_semaphore::release, and the NAME line says std::counting_semaphore::release - std::counting_semaphore::release, because repetition is iconic πŸ’….

🌸 Synopsis 🌸

void release( std::ptrdiff_t update = 1 );

Since: C++20 ✨

This atomically increments the internal counter by the value of update. Any thread(s) waiting for the counter to be greater than 0 β€” like because they’re blocked in acquire β€” will subsequently be unblocked. Slay, wake-up call delivered 🫢.

πŸŽ€ Preconditions πŸŽ€

Both of these need to be true, no cap:

  • update >= 0
  • update <= max() - counter

…where counter is the value of the internal counter. Both conditions are part of the contract, so don’t skip the vibe check 😭.

πŸ’– Parameters πŸ’–

  • update β€” the amount to increment the internal counter by.

πŸ¦‹ Exceptions πŸ¦‹

May throw std::system_error. Not a cute surprise, but there it is πŸ™ˆ.

🌈 See also 🌈

  • acquire β€” decrements the internal counter or blocks until it can (public member function).
  • try_acquire β€” tries to decrement the internal counter without blocking (public member function).
  • try_acquire_for β€” tries to decrement the internal counter, blocking for up to a duration time (public member function).
  • try_acquire_until β€” tries to decrement the internal counter, blocking until a point in time (public member function).

mwah πŸ’‹ β€” source/version: http://cppreference.com, dated 2024.06.10. That’s the whole page, bestie β€” go flex those semaphores responsibly 🌟

πŸ“¦ where this page comes from