libnx  v4.6.0
Data Structures | Functions
rwlock.h File Reference

Read/write lock synchronization primitive. More...

#include "../kernel/mutex.h"
#include "../kernel/condvar.h"

Go to the source code of this file.

Data Structures

struct  RwLock
 Read/write lock structure. More...
 

Functions

void rwlockInit (RwLock *r)
 Initializes the read/write lock. More...
 
void rwlockReadLock (RwLock *r)
 Locks the read/write lock for reading. More...
 
bool rwlockTryReadLock (RwLock *r)
 Attempts to lock the read/write lock for reading without waiting. More...
 
void rwlockReadUnlock (RwLock *r)
 Unlocks the read/write lock for reading. More...
 
void rwlockWriteLock (RwLock *r)
 Locks the read/write lock for writing. More...
 
bool rwlockTryWriteLock (RwLock *r)
 Attempts to lock the read/write lock for writing without waiting. More...
 
void rwlockWriteUnlock (RwLock *r)
 Unlocks the read/write lock for writing. More...
 
bool rwlockIsWriteLockHeldByCurrentThread (RwLock *r)
 Checks if the write lock is held by the current thread. More...
 
bool rwlockIsOwnedByCurrentThread (RwLock *r)
 Checks if the read/write lock is owned by the current thread. More...
 

Detailed Description

Read/write lock synchronization primitive.

Author
plutoo, SciresM

Function Documentation

◆ rwlockInit()

void rwlockInit ( RwLock r)

Initializes the read/write lock.

Parameters
rRead/write lock object.

◆ rwlockIsOwnedByCurrentThread()

bool rwlockIsOwnedByCurrentThread ( RwLock r)

Checks if the read/write lock is owned by the current thread.

Parameters
rRead/write lock object.
Returns
1 if the current hold holds the write lock or if it holds read locks acquired while it held the write lock, and 0 if it does not.

◆ rwlockIsWriteLockHeldByCurrentThread()

bool rwlockIsWriteLockHeldByCurrentThread ( RwLock r)

Checks if the write lock is held by the current thread.

Parameters
rRead/write lock object.
Returns
1 if the current hold holds the write lock, and 0 if it does not.

◆ rwlockReadLock()

void rwlockReadLock ( RwLock r)

Locks the read/write lock for reading.

Parameters
rRead/write lock object.

◆ rwlockReadUnlock()

void rwlockReadUnlock ( RwLock r)

Unlocks the read/write lock for reading.

Parameters
rRead/write lock object.

◆ rwlockTryReadLock()

bool rwlockTryReadLock ( RwLock r)

Attempts to lock the read/write lock for reading without waiting.

Parameters
rRead/write lock object.
Returns
1 if the mutex has been acquired successfully, and 0 on contention.

◆ rwlockTryWriteLock()

bool rwlockTryWriteLock ( RwLock r)

Attempts to lock the read/write lock for writing without waiting.

Parameters
rRead/write lock object.
Returns
1 if the mutex has been acquired successfully, and 0 on contention.

◆ rwlockWriteLock()

void rwlockWriteLock ( RwLock r)

Locks the read/write lock for writing.

Parameters
rRead/write lock object.

◆ rwlockWriteUnlock()

void rwlockWriteUnlock ( RwLock r)

Unlocks the read/write lock for writing.

Parameters
rRead/write lock object.