diff options
author | Chris Robinson <[email protected]> | 2011-08-29 19:15:22 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2011-08-29 19:15:22 -0700 |
commit | b283dd3682e5c56483e69c4b65e889563e95d8c0 (patch) | |
tree | da8c0a315549ef88f6506df8be0c091d64231dce /OpenAL32 | |
parent | 4a5dd73a3cd38c20b4b2ca45026167eb5ce0bc95 (diff) |
Use a read-write lock to protect access to the UInt maps
Diffstat (limited to 'OpenAL32')
-rw-r--r-- | OpenAL32/Include/alMain.h | 50 |
1 files changed, 32 insertions, 18 deletions
diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h index a9f5813d..fd645218 100644 --- a/OpenAL32/Include/alMain.h +++ b/OpenAL32/Include/alMain.h @@ -161,22 +161,6 @@ typedef ptrdiff_t ALsizeiptrEXT; #endif -typedef struct UIntMap { - struct { - ALuint key; - ALvoid *value; - } *array; - ALsizei size; - ALsizei maxsize; -} UIntMap; - -void InitUIntMap(UIntMap *map); -void ResetUIntMap(UIntMap *map); -ALenum InsertUIntMapEntry(UIntMap *map, ALuint key, ALvoid *value); -void RemoveUIntMapKey(UIntMap *map, ALuint key); -ALvoid *LookupUIntMapKey(UIntMap *map, ALuint key); - - #ifdef _WIN32 #ifndef _WIN32_WINNT @@ -184,8 +168,6 @@ ALvoid *LookupUIntMapKey(UIntMap *map, ALuint key); #endif #include <windows.h> -extern UIntMap TlsDestructor; - typedef DWORD pthread_key_t; int pthread_key_create(pthread_key_t *key, void (*callback)(void*)); int pthread_key_delete(pthread_key_t key); @@ -309,6 +291,38 @@ DECL_TEMPLATE(ALenum) #undef DECL_TEMPLATE +typedef struct { + volatile RefCount read_count; + volatile RefCount write_count; + volatile ALenum read_lock; + volatile ALenum read_entry_lock; + volatile ALenum write_lock; +} RWLock; + +void ReadLock(RWLock *lock); +void ReadUnlock(RWLock *lock); +void WriteLock(RWLock *lock); +void WriteUnlock(RWLock *lock); + + +typedef struct UIntMap { + struct { + ALuint key; + ALvoid *value; + } *array; + ALsizei size; + ALsizei maxsize; + RWLock lock; +} UIntMap; +extern UIntMap TlsDestructor; + +void InitUIntMap(UIntMap *map); +void ResetUIntMap(UIntMap *map); +ALenum InsertUIntMapEntry(UIntMap *map, ALuint key, ALvoid *value); +void RemoveUIntMapKey(UIntMap *map, ALuint key); +ALvoid *LookupUIntMapKey(UIntMap *map, ALuint key); + + #include "alListener.h" #include "alu.h" |