1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-25 20:22:30 +01:00
rpcs3/Utilities/SSemaphore.h

41 lines
539 B
C
Raw Normal View History

#pragma once
class SSemaphore
{
const u32 m_max;
u32 m_count;
2014-06-25 00:16:44 +02:00
u32 m_in_order;
u32 m_out_order;
2014-06-25 23:59:23 +02:00
std::mutex m_cv_mutex;
std::mutex m_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)
2014-06-25 00:16:44 +02:00
, m_in_order(0)
, m_out_order(0)
{
}
SSemaphore()
: m_max(0xffffffff)
, m_count(0)
2014-06-25 00:16:44 +02:00
, m_in_order(0)
, m_out_order(0)
{
}
~SSemaphore()
{
}
2014-06-25 00:16:44 +02:00
void wait();
bool try_wait();
2014-06-21 16:26:37 +02:00
void post();
bool post_and_wait();
};