NNG_MTX_LOCK(3supp)

πŸ“¦ version 1.11, in alpine 3.24

✨ 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