mirror of
https://github.com/RPCSX/rpcsx.git
synced 2026-04-04 22:19:02 +00:00
[orbis-kernel] Hopefully fix shared_cv
This commit is contained in:
parent
99f520491c
commit
3d78443496
4 changed files with 62 additions and 29 deletions
|
|
@ -10,7 +10,9 @@ inline namespace utils {
|
|||
class shared_cv {
|
||||
enum : unsigned {
|
||||
c_waiter_mask = 0xffff,
|
||||
c_signal_mask = 0xffffffff & ~c_waiter_mask,
|
||||
c_signal_mask = 0x7fff0000,
|
||||
c_locked_mask = 0x80000000,
|
||||
c_signal_one = c_waiter_mask + 1,
|
||||
};
|
||||
|
||||
std::atomic<unsigned> m_value{0};
|
||||
|
|
|
|||
|
|
@ -7,7 +7,9 @@
|
|||
namespace orbis {
|
||||
inline namespace utils {
|
||||
// IPC-ready shared mutex, using only writer lock is recommended
|
||||
struct shared_mutex final {
|
||||
class shared_mutex final {
|
||||
friend class shared_cv;
|
||||
|
||||
enum : unsigned {
|
||||
c_one = 1u << 14, // Fixed-point 1.0 value (one writer)
|
||||
c_sig = 1u << 30,
|
||||
|
|
@ -102,8 +104,9 @@ public:
|
|||
// Check whether can immediately obtain a shared (reader) lock
|
||||
bool is_lockable() const { return m_value.load() < c_one - 1; }
|
||||
|
||||
private:
|
||||
// For CV
|
||||
unsigned lock_forced();
|
||||
bool lock_forced(int count = 1);
|
||||
};
|
||||
|
||||
// Simplified shared (reader) lock implementation.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue