mirror of
https://github.com/thunderbrewhq/squall.git
synced 2025-12-12 02:22:30 +00:00
feat(thread): add SSemaphore
This commit is contained in:
parent
83cd9b05c0
commit
6437796094
3 changed files with 29 additions and 0 deletions
|
|
@ -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 <cstdint>
|
||||
|
|
|
|||
15
storm/thread/SSemaphore.cpp
Normal file
15
storm/thread/SSemaphore.cpp
Normal file
|
|
@ -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
|
||||
}
|
||||
13
storm/thread/SSemaphore.hpp
Normal file
13
storm/thread/SSemaphore.hpp
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
#ifndef STORM_THREAD_S_SEMAPHORE_HPP
|
||||
#define STORM_THREAD_S_SEMAPHORE_HPP
|
||||
|
||||
#include "storm/thread/SSyncObject.hpp"
|
||||
#include <cstdint>
|
||||
|
||||
class SSemaphore : public SSyncObject {
|
||||
public:
|
||||
// Member functions
|
||||
SSemaphore(uint32_t initialCount, uint32_t maximumCount);
|
||||
};
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue