summaryrefslogtreecommitdiff
path: root/include/dolphin/os/OSMutex.h
blob: 9ee6ffe3ee14a5cd5d1b2684d63b1c7b3778090e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#ifndef _DOLPHIN_OSMUTEX
#define _DOLPHIN_OSMUTEX

#include "types.h"

#include "dolphin/os/OSThread.h"

#ifdef __cplusplus
extern "C" {
#endif

struct OSMutex {
  OSThreadQueue queue;
  OSThread* thread; // the current owner
  s32 count;        // lock count
  OSMutexLink link; // for OSThread.queueMutex
};

struct OSCond {
  OSThreadQueue queue;
};

void OSInitMutex(OSMutex* mutex);
void OSLockMutex(OSMutex* mutex);
void OSUnlockMutex(OSMutex* mutex);
BOOL OSTryLockMutex(OSMutex* mutex);
void OSInitCond(OSCond* cond);
void OSWaitCond(OSCond* cond, OSMutex* mutex);
void OSSignalCond(OSCond* cond);

#ifdef __cplusplus
}
#endif

#endif // _DOLPHIN_OSMUTEX