NNG_CV_WAIT(3supp)
πΈ NAME πΈ
nng_cv_wait β wait for condition. This cutie lives in the NNG Reference Manual, section 3supp (folding the manual name in right here, bestie, instead of copying that header line π).
β¨ SYNOPSIS β¨
#include <nng/nng.h>
void nng_cv_wait(nng_cv *cv);
π DESCRIPTION π
Okay so nng_cv_wait() waits for the condition variable cv to be signaled by another thread calling either nng_cv_wake() or nng_cv_wake1(). That's the whole vibe π
.
The caller must have ownership of the mutex that was used when cv was allocated. This function will drop the ownership of that mutex, and reacquire it atomically just before returning to the caller. (The waiting is done without holding the mutex.) No cap, that part is important π₯.
Note π«Ά Any condition may be used or checked, but the condition must be checked, because it is possible for this function to wake up spuriously π. The best way to do this is inside a loop that repeats until the condition tests for true. Protect your peace and loop it, bestie.
π EXAMPLE π
The following example demonstrates use of this function:
Example 1: Waiting for the condition
nng_mtx_lock(m); // assume cv was allocated using m
while (!condition_true) {
nng_cv_wait(cv);
}
// condition_true is true
nng_mtx_unlock(m);
Example 2: Signaling the condition
nng_mtx_lock(m);
condition_true = true;
nng_cv_wake(cv);
nng_mtx_unlock(m);
π¦ RETURN VALUES π¦
None. Literally none. β¨
π ERRORS π
None. Also none. Iconic, honestly.
π₯ SEE ALSO π₯
nng_cv_alloc(3supp)nng_cv_until(3supp)nng_cv_wake(3supp)nng_cv_wake1(3supp)nng_mtx_alloc(3supp)nng_mtx_lock(3supp)nng_mtx_unlock(3supp)nng(7)
That's the whole page, bestie π β source/version: NNG Reference Manual / NNG_CV_WAIT(3supp), dated 2026-01-13. Periodt. π«Άπ
π¦ where this page comes from
- alpine 3.24: nng-doc 1.11-r0 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms