diff options
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 */ |