mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-14 10:48:36 +12:00
SSemaphore basic implementation
Set for RSX
This commit is contained in:
parent
7fca980887
commit
1c4ae999d6
8 changed files with 127 additions and 18 deletions
34
Utilities/SSemaphore.h
Normal file
34
Utilities/SSemaphore.h
Normal file
|
@ -0,0 +1,34 @@
|
|||
#pragma once
|
||||
|
||||
class SSemaphore
|
||||
{
|
||||
const u32 m_max;
|
||||
u32 m_count;
|
||||
std::mutex m_mutex, m_cv_mutex;
|
||||
std::condition_variable m_cond;
|
||||
|
||||
public:
|
||||
SSemaphore(u32 value, u32 max = 1)
|
||||
: m_max(max > 0 ? max : 0xffffffff)
|
||||
, m_count(value > m_max ? m_max : value)
|
||||
{
|
||||
}
|
||||
|
||||
SSemaphore()
|
||||
: m_max(0xffffffff)
|
||||
, m_count(0)
|
||||
{
|
||||
}
|
||||
|
||||
~SSemaphore()
|
||||
{
|
||||
}
|
||||
|
||||
bool wait(u64 timeout = 0);
|
||||
|
||||
bool try_wait();
|
||||
|
||||
void post(u32 value = 1);
|
||||
|
||||
bool post_and_wait();
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue