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-24 22:16:44 +00:00
u32 m_in_order;
u32 m_out_order;
2014-06-25 21:59:23 +00: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-24 22:16:44 +00:00
, m_in_order(0)
, m_out_order(0)
{
}
SSemaphore()
: m_max(0xffffffff)
, m_count(0)
2014-06-24 22:16:44 +00:00
, m_in_order(0)
, m_out_order(0)
{
}
~SSemaphore()
{
}
2014-06-24 22:16:44 +00:00
void wait();
bool try_wait();
2014-06-21 14:26:37 +00:00
void post();
bool post_and_wait();
};