std::condition_variable(3)

πŸ’– std::condition_variable β€” the Library Functions Manual era πŸ’–

okay so bestie, welcome to the libstdc++ manual page for std::condition_variable(3), which is filed under Library Functions Manual and lives in the std::condition_variable section of your heart. yes we're doing this. grab a boba. πŸ§‹


🌸 NAME 🌸

std::condition_variable β€” condition_variable πŸ’…

like. that's the whole name. it's giving minimalism. it's giving "the class name is the description." iconic behaviour honestly.


✨ SYNOPSIS ✨

#include <condition_variable>

that's it, that's the include. no extra headers, no drama, no #defines you have to fight with. just vibes and a header file. πŸ¦‹

🌈 Public Types 🌈

one (1) public type, and she's a legend:

  • typedef __gthread_cond_t * native_handle_type β€” the raw, underlying, native handle type. the actual guts of the thing, as a pointer to __gthread_cond_t. iykyk.

πŸŽ€ Public Member Functions πŸŽ€

okay here comes the lineup, no skips, every single one of them, periodt:

  • condition_variable(const condition_variable &) = delete β€” nope, can't copy-construct her. she said "no duplicates." πŸ’€
  • native_handle_type native_handle() β€” hands you the native handle. the real one. the native_handle_type one.
  • void notify_all() noexcept β€” wakes up everybody waiting. and she does it noexcept, because she does not have time to throw. πŸ”₯
  • void notify_one() noexcept β€” wakes up exactly one (1) lucky waiter. also noexcept. also unbothered.
  • condition_variable & operator=(const condition_variable &) = delete β€” and no copy-assignment either, bestie. she is not clonable. = delete said what it said. πŸ™ˆ
  • void wait(unique_lock<mutex> &__lock) β€” takes your unique_lock<mutex> by reference and just… waits. classic.
  • template<typename _Predicate> void wait(unique_lock<mutex> &__lock, _Predicate __p) β€” the templated glow-up: same lock, plus a _Predicate __p so you're not sitting there re-checking by hand.
  • template<typename _Rep, typename _Period> cv_status wait_for(unique_lock<mutex> &__lock, const chrono::duration<_Rep, _Period> &__rtime) β€” waiting, but with a deadline-shaped chrono::duration<_Rep, _Period> called __rtime. returns cv_status, because sometimes you just gotta know.
  • template<typename _Rep, typename _Period, typename _Predicate> bool wait_for(unique_lock<mutex> &__lock, const chrono::duration<_Rep, _Period> &__rtime, _Predicate __p) β€” the wait_for with a _Predicate __p on top, and this one returns bool. yes the return type changed, no we don't need to talk about it.
  • template<typename _Clock, typename _Duration> cv_status wait_until(unique_lock<mutex> &__lock, const chrono::time_point<_Clock, _Duration> &__atime) β€” waiting until an actual chrono::time_point<_Clock, _Duration> named __atime. returns cv_status.
  • template<typename _Clock, typename _Duration, typename _Predicate> bool wait_until(unique_lock<mutex> &__lock, const chrono::time_point<_Clock, _Duration> &__atime, _Predicate __p) β€” same time_point<_Clock, _Duration> energy, plus _Predicate __p, and it returns bool.
  • template<typename _Duration> cv_status wait_until(unique_lock<mutex> &__lock, const chrono::time_point<steady_clock, _Duration> &__atime) β€” special friend for steady_clock. cv_status return, _Duration template, __atime by reference. πŸ’œ
  • template<typename _Duration> cv_status wait_until(unique_lock<mutex> &__lock, const chrono::time_point<system_clock, _Duration> &__atime) β€” and the matching special friend for system_clock. same shape, different clock, she's got range. ⭐
lowkey the way there are two wait_fors and four wait_untils and they return cv_status or bool depending on whether you brought a predicate… that's the whole personality. and we love her for it. 🫢

πŸ¦‹ Detailed Description πŸ¦‹

condition_variable

yes. that's the detailed description. the detailed-est. we've been blessed with the maximum amount of detail. 😭 Doxygen really said "she speaks for herself."


πŸ‘‘ Author πŸ‘‘

Generated automatically by Doxygen for libstdc++ from the source code.

which is to say: no human author is credited here, she was generated by Doxygen, from the source code, for libstdc++. the source code is her mother. 🧚


πŸ’œ SEE ALSO πŸ’œ

okay so this page doesn't actually have a SEE ALSO section, but honestly? the wait, notify_one and notify_all members are the see-also. look at them. look at her. she's the whole ecosystem.


and that's the page, bestie!! that was std::condition_variable(3) from the Library Functions Manual, brought to you by libstdc++. mwah. go notify_all on your friends. πŸ’–βœ¨πŸŽ€πŸ¦‹πŸŒΈπŸ’…πŸ«ΆπŸ”₯πŸ‘‘πŸŒˆβ­πŸ’€πŸ™ˆπŸ“πŸ§šπŸ’œ

πŸ“¦ where this page comes from
  • arch rolling: gcc 16.2.1+r23+gd564253eb6c8-1 Β· GPL-3.0-or-later WITH GCC-exception-3.1 AND GFDL-1.3-or-later
  • fedora 44: libstdc++-docs 16.0.1-0.10.fc44 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
  • fedora 44: libstdc++-docs 16.2.1-2.fc44
  • fedora 44: libstdc++-docs 16.2.1-3.fc44 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms