123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- #pragma once
- #include "../C/Baselib_HighCapacitySemaphore.h"
- #include "Time.h"
- namespace baselib
- {
- BASELIB_CPP_INTERFACE
- {
-
-
- class HighCapacitySemaphore
- {
- public:
-
- HighCapacitySemaphore(const HighCapacitySemaphore& other) = delete;
- HighCapacitySemaphore& operator=(const HighCapacitySemaphore& other) = delete;
-
- HighCapacitySemaphore(HighCapacitySemaphore&& other) = delete;
- HighCapacitySemaphore& operator=(HighCapacitySemaphore&& other) = delete;
-
-
-
- enum : int64_t { MaxGuaranteedCount = Baselib_HighCapacitySemaphore_MaxGuaranteedCount };
-
-
- HighCapacitySemaphore() : m_SemaphoreData(Baselib_HighCapacitySemaphore_Create())
- {
- }
-
-
-
- ~HighCapacitySemaphore()
- {
- Baselib_HighCapacitySemaphore_Free(&m_SemaphoreData);
- }
-
-
-
- inline void Acquire()
- {
- return Baselib_HighCapacitySemaphore_Acquire(&m_SemaphoreData);
- }
-
-
-
-
-
- inline bool TryAcquire()
- {
- return Baselib_HighCapacitySemaphore_TryAcquire(&m_SemaphoreData);
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- inline bool TryTimedAcquire(const timeout_ms timeoutInMilliseconds)
- {
- return Baselib_HighCapacitySemaphore_TryTimedAcquire(&m_SemaphoreData, timeoutInMilliseconds.count());
- }
-
-
-
-
-
-
- inline void Release(uint32_t count)
- {
- return Baselib_HighCapacitySemaphore_Release(&m_SemaphoreData, count);
- }
-
-
-
-
-
- inline uint64_t ResetAndReleaseWaitingThreads()
- {
- return Baselib_HighCapacitySemaphore_ResetAndReleaseWaitingThreads(&m_SemaphoreData);
- }
- private:
- Baselib_HighCapacitySemaphore m_SemaphoreData;
- };
- }
- }
|