123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- #pragma once
- #include "../C/Baselib_CappedSemaphore.h"
- #include "Time.h"
- namespace baselib
- {
- BASELIB_CPP_INTERFACE
- {
-
-
-
-
-
-
-
-
-
-
-
-
-
- class CappedSemaphore
- {
- public:
-
- CappedSemaphore(const CappedSemaphore& other) = delete;
- CappedSemaphore& operator=(const CappedSemaphore& other) = delete;
-
- CappedSemaphore(CappedSemaphore&& other) = delete;
- CappedSemaphore& operator=(CappedSemaphore&& other) = delete;
-
-
-
-
- CappedSemaphore(const uint16_t cap) : m_CappedSemaphoreData(Baselib_CappedSemaphore_Create(cap))
- {
- }
-
-
-
- ~CappedSemaphore()
- {
- Baselib_CappedSemaphore_Free(&m_CappedSemaphoreData);
- }
-
-
-
- inline void Acquire()
- {
- return Baselib_CappedSemaphore_Acquire(&m_CappedSemaphoreData);
- }
-
-
-
-
-
- inline bool TryAcquire()
- {
- return Baselib_CappedSemaphore_TryAcquire(&m_CappedSemaphoreData);
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- inline bool TryTimedAcquire(const timeout_ms timeoutInMilliseconds)
- {
- return Baselib_CappedSemaphore_TryTimedAcquire(&m_CappedSemaphoreData, timeoutInMilliseconds.count());
- }
-
-
-
-
-
-
- inline uint16_t Release(const uint16_t count)
- {
- return Baselib_CappedSemaphore_Release(&m_CappedSemaphoreData, count);
- }
-
-
-
-
-
- inline uint32_t ResetAndReleaseWaitingThreads()
- {
- return Baselib_CappedSemaphore_ResetAndReleaseWaitingThreads(&m_CappedSemaphoreData);
- }
- private:
- Baselib_CappedSemaphore m_CappedSemaphoreData;
- };
- }
- }
|