nanomsg next generation NNG  
Home GitHub Documentation

This documentation is for version v1.0.0 of nng, but the latest released version is v1.8.0. see the documentation for v1.8.0 for the most up-to-date information.
nng_mtx_lock(3supp)

SYNOPSIS

#include <nng/nng.h>
#include <nng/supplemental/util/platform.h>

void nng_mtx_lock(nng_mtx *mtx);

DESCRIPTION

The nng_mtx_lock() acquires exclusive ownership of the mutex mtx. If the lock is already owned, this function will wait until the current owner releases it with nng_mtx_unlock().

If multiple threads are waiting for the lock, the order of acquisition is not specified.

A mutex can only be unlocked by the thread that locked it.
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.

nng offers neither a “trylock” operation, nor recursive mutexes. This is by design, as nng itself does not use such things, and most often the need for them is the result of poor design. If such capabilities are needed, they may be synthesized fairly easily from mutexes and condition variables.

RETURN VALUES

None.

ERRORS

None.

NNG Reference Manual vv1.0.0 © 2019 Staysail Systems, Inc, © 2018 Capitar IT Group BV
This document is supplied under the MIT License.
nanomsg™ and nng™ are trademarks of Garrett D'Amore.