aboutsummaryrefslogtreecommitdiffstats
path: root/common/threads.h
diff options
context:
space:
mode:
Diffstat (limited to 'common/threads.h')
-rw-r--r--common/threads.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/common/threads.h b/common/threads.h
index a357b494..03a3899c 100644
--- a/common/threads.h
+++ b/common/threads.h
@@ -63,6 +63,26 @@ int alsem_trywait(alsem_t *sem);
#ifdef __cplusplus
} // extern "C"
+
+namespace al {
+
+class semaphore {
+ alsem_t mSem;
+
+public:
+ semaphore(unsigned int initial=0);
+ semaphore(const semaphore&) = delete;
+ ~semaphore();
+
+ semaphore& operator=(const semaphore&) = delete;
+
+ void post();
+ void wait() noexcept;
+ int trywait() noexcept;
+};
+
+} // namespace al
+
#endif
#endif /* AL_THREADS_H */