NNG_MTX_LOCK(3supp)
β¨ NAME β¨
nng_mtx_lock β lock a mutex, bestie π
(this is from the NNG Reference Manual, section 3supp, and yes she's iconic)
πΈ SYNOPSIS πΈ
#include <nng/nng.h>
void nng_mtx_lock(nng_mtx *mtx);
π DESCRIPTION π
Okay so nng_mtx_lock() grabs exclusive ownership of the mutex mtx. Like, it's yours now, nobody else gets in π.
If the lock is already owned by someone else, this function will simply wait until the current owner releases it with nng_mtx_unlock(). Patient queen behavior honestly π§
If multiple threads are all waiting for the lock? The order of acquisition is not specified β so it's giving chaos, not a queue, and you literally cannot predict who gets it next π
Note π«Ά A mutex can only be unlocked by the thread that locked it. No proxy unlocking, no handing it off, periodt.
Important π₯ Mutex locks are not recursive. Attempts to reacquire the same mutex may result in deadlock or aborting the current program π It is a programming error for the owner of a mutex to attempt to reacquire it. Do not do this, I'm begging you π
β RETURN VALUES β
None. She returns nothing, she just does her job π
π¦ ERRORS π¦
None. Zero errors, zero drama, we love a low-maintenance function β¨
π SEE ALSO π
mwah π that's the whole page, written by the NNG crew (NNG Reference Manual, dated 2026-01-13) β go lock something responsibly, bestie π
π¦ 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