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. thenative_handle_typeone.void notify_all() noexceptβ wakes up everybody waiting. and she does itnoexcept, because she does not have time to throw. π₯void notify_one() noexceptβ wakes up exactly one (1) lucky waiter. alsonoexcept. also unbothered.condition_variable & operator=(const condition_variable &) = deleteβ and no copy-assignment either, bestie. she is not clonable.= deletesaid what it said. πvoid wait(unique_lock<mutex> &__lock)β takes yourunique_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 __pso 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-shapedchrono::duration<_Rep, _Period>called__rtime. returnscv_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)β thewait_forwith a_Predicate __pon top, and this one returnsbool. 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 actualchrono::time_point<_Clock, _Duration>named__atime. returnscv_status.template<typename _Clock, typename _Duration, typename _Predicate> bool wait_until(unique_lock<mutex> &__lock, const chrono::time_point<_Clock, _Duration> &__atime, _Predicate __p)β sametime_point<_Clock, _Duration>energy, plus_Predicate __p, and it returnsbool.template<typename _Duration> cv_status wait_until(unique_lock<mutex> &__lock, const chrono::time_point<steady_clock, _Duration> &__atime)β special friend forsteady_clock.cv_statusreturn,_Durationtemplate,__atimeby 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 forsystem_clock. same shape, different clock, she's got range. β
lowkey the way there are twowait_fors and fourwait_untils and they returncv_statusorbooldepending 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