mirror of
https://github.com/switchbrew/libnx.git
synced 2025-06-21 12:32:40 +02:00
46 lines
895 B
C
46 lines
895 B
C
/**
|
|
* @file rwlock.h
|
|
* @brief Read/write lock synchronization primitive.
|
|
* @author plutoo
|
|
* @copyright libnx Authors
|
|
*/
|
|
#pragma once
|
|
#include "../kernel/mutex.h"
|
|
|
|
/// Read/write lock structure.
|
|
typedef struct {
|
|
RMutex r;
|
|
RMutex g;
|
|
u64 b;
|
|
} RwLock;
|
|
|
|
/**
|
|
* @brief Initializes the read/write lock.
|
|
* @param r Read/write lock object.
|
|
*/
|
|
void rwlockInit(RwLock* r);
|
|
|
|
/**
|
|
* @brief Locks the read/write lock for reading.
|
|
* @param r Read/write lock object.
|
|
*/
|
|
void rwlockReadLock(RwLock* r);
|
|
|
|
/**
|
|
* @brief Unlocks the read/write lock for reading.
|
|
* @param r Read/write lock object.
|
|
*/
|
|
void rwlockReadUnlock(RwLock* r);
|
|
|
|
/**
|
|
* @brief Locks the read/write lock for writing.
|
|
* @param r Read/write lock object.
|
|
*/
|
|
void rwlockWriteLock(RwLock* r);
|
|
|
|
/**
|
|
* @brief Unlocks the read/write lock for writing.
|
|
* @param r Read/write lock object.
|
|
*/
|
|
void rwlockWriteUnlock(RwLock* r);
|