Add methods for thread-local contexts to the router
[openal-soft.git] / common / rwlock.h
blob8e36fa1a71f9816912b366f8375b2215eb35a215
1 #ifndef AL_RWLOCK_H
2 #define AL_RWLOCK_H
4 #include "bool.h"
5 #include "atomic.h"
7 #ifdef __cplusplus
8 extern "C" {
9 #endif
11 typedef struct {
12 RefCount read_count;
13 RefCount write_count;
14 ATOMIC_FLAG read_lock;
15 ATOMIC_FLAG read_entry_lock;
16 ATOMIC_FLAG write_lock;
17 } RWLock;
18 #define RWLOCK_STATIC_INITIALIZE { ATOMIC_INIT_STATIC(0), ATOMIC_INIT_STATIC(0), \
19 ATOMIC_FLAG_INIT, ATOMIC_FLAG_INIT, ATOMIC_FLAG_INIT }
21 void RWLockInit(RWLock *lock);
22 void ReadLock(RWLock *lock);
23 void ReadUnlock(RWLock *lock);
24 void WriteLock(RWLock *lock);
25 void WriteUnlock(RWLock *lock);
27 #ifdef __cplusplus
29 #endif
31 #endif /* AL_RWLOCK_H */