diff options
author | Chris Robinson <[email protected]> | 2018-10-30 13:47:01 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2018-10-30 14:28:19 -0700 |
commit | f747ac8882b6ca618fe28e1a4252f89cc3fa0d8c (patch) | |
tree | 6e35d70af5481e741c171e848da87b302bc6be0b /router/router.h | |
parent | 44f91760b5d4d9c351100eb2b7b248309c6c32db (diff) |
Clean up the router's PtrIntMap
Diffstat (limited to 'router/router.h')
-rw-r--r-- | router/router.h | 40 |
1 files changed, 15 insertions, 25 deletions
diff --git a/router/router.h b/router/router.h index 3ac0ab40..96db56ea 100644 --- a/router/router.h +++ b/router/router.h @@ -8,8 +8,9 @@ #include <stdio.h> #include <vector> -#include <atomic> #include <string> +#include <atomic> +#include <mutex> #include "AL/alc.h" #include "AL/al.h" @@ -17,10 +18,6 @@ #include "rwlock.h" -#ifdef __cplusplus -extern "C" { -#endif - #ifndef UNUSED #if defined(__cplusplus) #define UNUSED(x) @@ -145,26 +142,23 @@ extern thread_local DriverIface *ThreadCtxDriver; extern std::atomic<DriverIface*> CurrentCtxDriver; -typedef struct PtrIntMap { - ALvoid **keys; +class PtrIntMap { + ALvoid **mKeys{nullptr}; /* Shares memory with keys. */ - ALint *values; + ALint *mValues{nullptr}; - ALsizei size; - ALsizei capacity; - RWLock lock; -} PtrIntMap; -#define PTRINTMAP_STATIC_INITIALIZE { nullptr, nullptr, 0, 0, RWLOCK_STATIC_INITIALIZE } + ALsizei mSize{0}; + ALsizei mCapacity{0}; + std::mutex mLock; -void InitPtrIntMap(PtrIntMap *map); -void ResetPtrIntMap(PtrIntMap *map); -ALenum InsertPtrIntMapEntry(PtrIntMap *map, ALvoid *key, ALint value); -ALint RemovePtrIntMapKey(PtrIntMap *map, ALvoid *key); -ALint LookupPtrIntMapKey(PtrIntMap *map, ALvoid *key); +public: + PtrIntMap() = default; + ~PtrIntMap(); - -void InitALC(void); -void ReleaseALC(void); + ALenum insert(ALvoid *key, ALint value); + ALint removeByKey(ALvoid *key); + ALint lookupByKey(ALvoid *key); +}; enum LogLevel { @@ -198,8 +192,4 @@ extern FILE *LogFile; } \ } while(0) -#ifdef __cplusplus -} // extern "C" -#endif - #endif /* ROUTER_ROUTER_H */ |