DDraceNetwork Documentation
Loading...
Searching...
No Matches
threading.h
Go to the documentation of this file.
1#ifndef BASE_TL_THREADING_H
2#define BASE_TL_THREADING_H
3
4#include "../system.h"
5
6#include <atomic>
7
9{
11 // implement the counter separately, because the `sem_getvalue`-API is
12 // deprecated on macOS: https://stackoverflow.com/a/16655541
13 std::atomic_int m_Count{0};
14
15public:
18 CSemaphore(const CSemaphore &) = delete;
19 int GetApproximateValue() { return m_Count.load(); }
20 void Wait()
21 {
23 m_Count.fetch_sub(1);
24 }
25 void Signal()
26 {
27 m_Count.fetch_add(1);
29 }
30};
31
32#endif // BASE_TL_THREADING_H
~CSemaphore()
Definition threading.h:17
std::atomic_int m_Count
Definition threading.h:13
int GetApproximateValue()
Definition threading.h:19
CSemaphore()
Definition threading.h:16
void Wait()
Definition threading.h:20
SEMAPHORE m_Sem
Definition threading.h:10
CSemaphore(const CSemaphore &)=delete
void Signal()
Definition threading.h:25
void sphore_signal(SEMAPHORE *sem)
Definition system.cpp:863
void sphore_destroy(SEMAPHORE *sem)
Definition system.cpp:867
void sphore_init(SEMAPHORE *sem)
Definition system.cpp:850
void sphore_wait(SEMAPHORE *sem)
Definition system.cpp:854
sem_t SEMAPHORE
Definition system.h:522