openal-soft/include/rwlock.h

33 lines
740 B
C
Raw Normal View History

2013-10-28 12:48:13 -07:00
#ifndef AL_RWLOCK_H
#define AL_RWLOCK_H
2014-05-07 01:03:06 -07:00
#include "bool.h"
2013-10-28 12:48:13 -07:00
#include "atomic.h"
2014-05-29 04:22:30 -07:00
#ifdef __cplusplus
extern "C" {
#endif
2013-10-28 12:48:13 -07:00
typedef struct {
RefCount read_count;
RefCount write_count;
2014-07-22 18:57:51 -07:00
ATOMIC(int) read_lock;
ATOMIC(int) read_entry_lock;
ATOMIC(int) write_lock;
2013-10-28 12:48:13 -07:00
} RWLock;
2014-07-22 18:57:51 -07:00
#define RWLOCK_STATIC_INITIALIZE { ATOMIC_INIT_STATIC(0), ATOMIC_INIT_STATIC(0), \
ATOMIC_INIT_STATIC(false), ATOMIC_INIT_STATIC(false), \
ATOMIC_INIT_STATIC(false) }
2013-10-28 12:48:13 -07:00
void RWLockInit(RWLock *lock);
void ReadLock(RWLock *lock);
void ReadUnlock(RWLock *lock);
void WriteLock(RWLock *lock);
void WriteUnlock(RWLock *lock);
2014-05-29 04:22:30 -07:00
#ifdef __cplusplus
}
#endif
2013-10-28 12:48:13 -07:00
#endif /* AL_RWLOCK_H */