diff --git a/storm/Thread.hpp b/storm/Thread.hpp index ad83c3b..0a0463e 100644 --- a/storm/Thread.hpp +++ b/storm/Thread.hpp @@ -4,6 +4,7 @@ #include "storm/thread/CSRWLock.hpp" #include "storm/thread/SCritSect.hpp" #include "storm/thread/SEvent.hpp" +#include "storm/thread/SSemaphore.hpp" #include "storm/thread/SSyncObject.hpp" #include "storm/thread/SThread.hpp" #include diff --git a/storm/thread/SSemaphore.cpp b/storm/thread/SSemaphore.cpp new file mode 100644 index 0000000..4111e76 --- /dev/null +++ b/storm/thread/SSemaphore.cpp @@ -0,0 +1,15 @@ +#include "storm/thread/SSemaphore.hpp" + +SSemaphore::SSemaphore(uint32_t initialCount, uint32_t maximumCount) + : SSyncObject() { +#if defined(WHOA_SYSTEM_WIN) + this->m_opaqueData = CreateSemaphoreA(nullptr, initialCount, maximumCount, nullptr); +#endif + +#if defined(WHOA_SYSTEM_MAC) || defined(WHOA_SYSTEM_LINUX) + this->m_value1 = initialCount; + this->m_value2 = maximumCount; + this->int0 = 4; + pthread_cond_init(&this->m_cond, 0); +#endif +} diff --git a/storm/thread/SSemaphore.hpp b/storm/thread/SSemaphore.hpp new file mode 100644 index 0000000..a9b064d --- /dev/null +++ b/storm/thread/SSemaphore.hpp @@ -0,0 +1,13 @@ +#ifndef STORM_THREAD_S_SEMAPHORE_HPP +#define STORM_THREAD_S_SEMAPHORE_HPP + +#include "storm/thread/SSyncObject.hpp" +#include + +class SSemaphore : public SSyncObject { + public: + // Member functions + SSemaphore(uint32_t initialCount, uint32_t maximumCount); +}; + +#endif