libnx
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...
 
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

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.
void mutexLock ( Mutex m)

Locks a mutex.

Parameters
mMutex object.
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.
void mutexUnlock ( Mutex m)

Unlocks a mutex.

Parameters
mMutex object.
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.
void rmutexLock ( RMutex m)

Locks a recursive mutex.

Parameters
mRecursive mutex object.
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.
void rmutexUnlock ( RMutex m)

Unlocks a recursive mutex.

Parameters
mRecursive mutex object.