libnx  v4.6.0
Typedefs | Functions
mutex.h File Reference

Mutex synchronization primitive. More...

#include <sys/lock.h>
#include "../types.h"

Go to the source code of this file.

Typedefs

typedef _LOCK_T Mutex
 Mutex datatype, defined in newlib.
 
typedef _LOCK_RECURSIVE_T RMutex
 Recursive mutex datatype, defined in newlib.
 

Functions

static void mutexInit (Mutex *m)
 Initializes a mutex. More...
 
void mutexLock (Mutex *m)
 Locks a mutex. More...
 
bool mutexTryLock (Mutex *m)
 Attempts to lock a mutex without waiting. More...
 
void mutexUnlock (Mutex *m)
 Unlocks a mutex. More...
 
bool mutexIsLockedByCurrentThread (const Mutex *m)
 Gets whether the current thread owns the mutex. More...
 
static void rmutexInit (RMutex *m)
 Initializes a recursive mutex. More...
 
void rmutexLock (RMutex *m)
 Locks a recursive mutex. More...
 
bool rmutexTryLock (RMutex *m)
 Attempts to lock a recursive mutex without waiting. More...
 
void rmutexUnlock (RMutex *m)
 Unlocks a recursive mutex. More...
 

Detailed Description

Mutex synchronization primitive.

Author
plutoo

Function Documentation

◆ mutexInit()

static void mutexInit ( Mutex m)
inlinestatic

Initializes a mutex.

Parameters
mMutex object.
Note
A mutex can also be statically initialized by assigning 0 to it.

◆ mutexIsLockedByCurrentThread()

bool mutexIsLockedByCurrentThread ( const Mutex m)

Gets whether the current thread owns the mutex.

Parameters
mMutex object.
Returns
1 if the mutex is locked by the current thread, and 0 otherwise.

◆ mutexLock()

void mutexLock ( Mutex m)

Locks a mutex.

Parameters
mMutex object.

◆ mutexTryLock()

bool mutexTryLock ( Mutex m)

Attempts to lock a mutex without waiting.

Parameters
mMutex object.
Returns
1 if the mutex has been acquired successfully, and 0 on contention.

◆ mutexUnlock()

void mutexUnlock ( Mutex m)

Unlocks a mutex.

Parameters
mMutex object.

◆ rmutexInit()

static void rmutexInit ( RMutex m)
inlinestatic

Initializes a recursive mutex.

Parameters
mRecursive mutex object.
Note
A recursive mutex can also be statically initialized by assigning {0,0,0} to it.

◆ rmutexLock()

void rmutexLock ( RMutex m)

Locks a recursive mutex.

Parameters
mRecursive mutex object.

◆ rmutexTryLock()

bool rmutexTryLock ( RMutex m)

Attempts to lock a recursive mutex without waiting.

Parameters
mRecursive mutex object.
Returns
1 if the mutex has been acquired successfully, and 0 on contention.

◆ rmutexUnlock()

void rmutexUnlock ( RMutex m)

Unlocks a recursive mutex.

Parameters
mRecursive mutex object.