ObjFW
Loading...
Searching...
No Matches
OFPlainMutex.h File Reference
#include "objfw-defs.h"
#include <errno.h>
#include "platform.h"
import "macros.h"
import "OFTLSKey.h"

Go to the source code of this file.

Functions

int OFPlainMutexNew (OFPlainMutex *mutex)
 Creates a new plain mutex.
 
int OFPlainMutexLock (OFPlainMutex *mutex)
 Locks the specified mutex.
 
int OFPlainMutexTryLock (OFPlainMutex *mutex)
 Tries to lock the specified mutex without blocking.
 
int OFPlainMutexUnlock (OFPlainMutex *mutex)
 Unlocks the specified mutex.
 
int OFPlainMutexFree (OFPlainMutex *mutex)
 Destroys the specified mutex.
 
int OFPlainRecursiveMutexNew (OFPlainRecursiveMutex *rmutex)
 Creates a new plain recursive mutex.
 
int OFPlainRecursiveMutexLock (OFPlainRecursiveMutex *rmutex)
 Locks the specified recursive mutex.
 
int OFPlainRecursiveMutexTryLock (OFPlainRecursiveMutex *rmutex)
 Tries to lock the specified recursive mutex without blocking.
 
int OFPlainRecursiveMutexUnlock (OFPlainRecursiveMutex *rmutex)
 Unlocks the specified recursive mutex.
 
int OFPlainRecursiveMutexFree (OFPlainRecursiveMutex *rmutex)
 Destroys the specified recursive mutex.
 
static OF_INLINE void OFYieldThread (void)
 Yield the current thread, indicating to the OS that another thread should execute instead.
 
static OF_INLINE int OFSpinlockNew (OFSpinlock *spinlock)
 Creates a new spinlock.
 
static OF_INLINE int OFSpinlockTryLock (OFSpinlock *spinlock)
 Tries to lock a spinlock.
 
static OF_INLINE int OFSpinlockLock (OFSpinlock *spinlock)
 Locks a spinlock.
 
static OF_INLINE int OFSpinlockUnlock (OFSpinlock *spinlock)
 Unlocks a spinlock.
 
static OF_INLINE int OFSpinlockFree (OFSpinlock *spinlock)
 Destroys a spinlock.
 

Function Documentation

◆ OFPlainMutexFree()

int OFPlainMutexFree ( OFPlainMutex * mutex)
extern

Destroys the specified mutex.

Parameters
mutexA pointer to the mutex to destruct
Returns
0 on success, or an error number from <errno.h> on error

◆ OFPlainMutexLock()

int OFPlainMutexLock ( OFPlainMutex * mutex)
extern

Locks the specified mutex.

Parameters
mutexA pointer to the mutex to lock
Returns
0 on success, or an error number from <errno.h> on error

◆ OFPlainMutexNew()

int OFPlainMutexNew ( OFPlainMutex * mutex)
extern

Creates a new plain mutex.

A plain mutex is similar to an OFMutex, but does not use exceptions and is just a lightweight wrapper around the system's mutex implementation.

Parameters
mutexA pointer to the mutex to create
Returns
0 on success, or an error number from <errno.h> on error

◆ OFPlainMutexTryLock()

int OFPlainMutexTryLock ( OFPlainMutex * mutex)
extern

Tries to lock the specified mutex without blocking.

Parameters
mutexA pointer to the mutex to try to lock
Returns
0 on success, or an error number from <errno.h> on error

◆ OFPlainMutexUnlock()

int OFPlainMutexUnlock ( OFPlainMutex * mutex)
extern

Unlocks the specified mutex.

Parameters
mutexA pointer to the mutex to unlock
Returns
0 on success, or an error number from <errno.h> on error

◆ OFPlainRecursiveMutexFree()

int OFPlainRecursiveMutexFree ( OFPlainRecursiveMutex * rmutex)
extern

Destroys the specified recursive mutex.

Parameters
rmutexA pointer to the recursive mutex to destruct
Returns
0 on success, or an error number from <errno.h> on error

◆ OFPlainRecursiveMutexLock()

int OFPlainRecursiveMutexLock ( OFPlainRecursiveMutex * rmutex)
extern

Locks the specified recursive mutex.

Parameters
rmutexA pointer to the recursive mutex to lock
Returns
0 on success, or an error number from <errno.h> on error

◆ OFPlainRecursiveMutexNew()

int OFPlainRecursiveMutexNew ( OFPlainRecursiveMutex * rmutex)
extern

Creates a new plain recursive mutex.

A plain recursive mutex is similar to an OFRecursiveMutex, but does not use exceptions and is just a lightweight wrapper around the system's recursive mutex implementation (or lacking that, a simple implementation of recursive mutexes via regular mutexes).

Parameters
rmutexA pointer to the recursive mutex to create
Returns
0 on success, or an error number from <errno.h> on error

◆ OFPlainRecursiveMutexTryLock()

int OFPlainRecursiveMutexTryLock ( OFPlainRecursiveMutex * rmutex)
extern

Tries to lock the specified recursive mutex without blocking.

Parameters
rmutexA pointer to the recursive mutex to try to lock
Returns
0 on success, or an error number from <errno.h> on error

◆ OFPlainRecursiveMutexUnlock()

int OFPlainRecursiveMutexUnlock ( OFPlainRecursiveMutex * rmutex)
extern

Unlocks the specified recursive mutex.

Parameters
rmutexA pointer to the recursive mutex to unlock
Returns
0 on success, or an error number from <errno.h> on error

◆ OFSpinlockFree()

static OF_INLINE int OFSpinlockFree ( OFSpinlock * spinlock)
static

Destroys a spinlock.

Parameters
spinlockA pointer to the spinlock to destroy
Returns
0 on success, or an error number from <errno.h> on error

◆ OFSpinlockLock()

static OF_INLINE int OFSpinlockLock ( OFSpinlock * spinlock)
static

Locks a spinlock.

Parameters
spinlockA pointer to the spinlock to lock
Returns
0 on success, or an error number from <errno.h> on error

◆ OFSpinlockNew()

static OF_INLINE int OFSpinlockNew ( OFSpinlock * spinlock)
static

Creates a new spinlock.

Parameters
spinlockA pointer to the spinlock to create
Returns
0 on success, or an error number from <errno.h> on error

◆ OFSpinlockTryLock()

static OF_INLINE int OFSpinlockTryLock ( OFSpinlock * spinlock)
static

Tries to lock a spinlock.

Parameters
spinlockA pointer to the spinlock to try to lock
Returns
0 on success, or an error number from <errno.h> on error

◆ OFSpinlockUnlock()

static OF_INLINE int OFSpinlockUnlock ( OFSpinlock * spinlock)
static

Unlocks a spinlock.

Parameters
spinlockA pointer to the spinlock to unlock
Returns
0 on success, or an error number from <errno.h> on error