Add a function to initialize a RWLock
This commit is contained in:
parent
ab0b5d9890
commit
dd74757319
@ -277,6 +277,15 @@ static void Unlock(volatile ALenum *l)
|
||||
ExchangeInt(l, AL_FALSE);
|
||||
}
|
||||
|
||||
void RWLockInit(RWLock *lock)
|
||||
{
|
||||
lock->read_count = 0;
|
||||
lock->write_count = 0;
|
||||
lock->read_lock = AL_FALSE;
|
||||
lock->read_entry_lock = AL_FALSE;
|
||||
lock->write_lock = AL_FALSE;
|
||||
}
|
||||
|
||||
void ReadLock(RWLock *lock)
|
||||
{
|
||||
Lock(&lock->read_entry_lock);
|
||||
@ -314,11 +323,7 @@ void InitUIntMap(UIntMap *map, ALsizei limit)
|
||||
map->size = 0;
|
||||
map->maxsize = 0;
|
||||
map->limit = limit;
|
||||
map->lock.read_count = 0;
|
||||
map->lock.write_count = 0;
|
||||
map->lock.read_lock = AL_FALSE;
|
||||
map->lock.read_entry_lock = AL_FALSE;
|
||||
map->lock.write_lock = AL_FALSE;
|
||||
RWLockInit(&map->lock);
|
||||
}
|
||||
|
||||
void ResetUIntMap(UIntMap *map)
|
||||
|
@ -321,6 +321,7 @@ typedef struct {
|
||||
volatile ALenum write_lock;
|
||||
} RWLock;
|
||||
|
||||
void RWLockInit(RWLock *lock);
|
||||
void ReadLock(RWLock *lock);
|
||||
void ReadUnlock(RWLock *lock);
|
||||
void WriteLock(RWLock *lock);
|
||||
|
@ -32,11 +32,7 @@ static RWLock ThunkLock;
|
||||
|
||||
void ThunkInit(void)
|
||||
{
|
||||
ThunkLock.read_count = 0;
|
||||
ThunkLock.write_count = 0;
|
||||
ThunkLock.read_lock = AL_FALSE;
|
||||
ThunkLock.read_entry_lock = AL_FALSE;
|
||||
ThunkLock.write_lock = AL_FALSE;
|
||||
RWLockInit(&ThunkLock);
|
||||
ThunkArraySize = 1;
|
||||
ThunkArray = calloc(1, ThunkArraySize * sizeof(*ThunkArray));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user