libnx/nx/include/switch/kernel/rwlock.h
Juan Antonio Hernández Cánovas 377683acd5 Add rwlockInit (#155)
2018-08-24 16:20:01 +02:00

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);