mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-17 08:11:51 +00:00
da7472fe81
* Optimizations 1) Some headers simplified for better compilation time 2) Some templates simplified for smaller executable size 3) Eliminate std::future to fix compilation for mingw64 4) PKG installation can be cancelled now 5) cellGame fixes 6) XAudio2 fix for mingw64 7) PPUInterpreter bug fixed (Clang) * any_pod<> implemented Aliases: any16, any32, any64 rsx::make_command fixed
41 lines
608 B
C++
41 lines
608 B
C++
#pragma once
|
|
|
|
#include "types.h"
|
|
#include "Atomic.h"
|
|
|
|
class semaphore_t
|
|
{
|
|
// semaphore mutex
|
|
std::mutex m_mutex;
|
|
|
|
// semaphore condition variable
|
|
std::condition_variable m_cv;
|
|
|
|
struct alignas(8) sync_var_t
|
|
{
|
|
u32 value; // current semaphore value
|
|
u32 waiters; // current amount of waiters
|
|
};
|
|
|
|
// current semaphore value
|
|
atomic_t<sync_var_t> m_var;
|
|
|
|
public:
|
|
// max semaphore value
|
|
const u32 max_value;
|
|
|
|
semaphore_t(u32 max_value = 1, u32 value = 0)
|
|
: m_var(sync_var_t{ value, 0 })
|
|
, max_value(max_value)
|
|
{
|
|
}
|
|
|
|
bool try_wait();
|
|
|
|
bool try_post();
|
|
|
|
void wait();
|
|
|
|
bool post_and_wait();
|
|
};
|