1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-25 04:02:42 +01:00

Remove unique_cond

Not very useful.
This commit is contained in:
Nekotekina 2019-09-09 04:41:47 +03:00
parent a808c2aaf6
commit 92a75cfa80
2 changed files with 0 additions and 95 deletions

View File

@ -54,54 +54,6 @@ void cond_variable::imp_wake(u32 _count) noexcept
}));
}
bool unique_cond::imp_wait(u64 _timeout) noexcept
{
// State transition: c_sig -> c_lock \ c_lock -> c_wait
const u32 _old = m_value.fetch_sub(1);
if (LIKELY(_old == c_sig))
return true;
return balanced_wait_until(m_value, _timeout, [&](u32& value, auto... ret) -> int
{
if (value == c_sig)
{
value = c_lock;
return +1;
}
if constexpr (sizeof...(ret))
{
value = c_lock;
return -1;
}
return 0;
});
}
void unique_cond::imp_notify() noexcept
{
auto [old, ok] = m_value.fetch_op([](u32& v)
{
if (UNLIKELY(v > 0 && v < c_sig))
{
v = c_sig;
return true;
}
return false;
});
verify(HERE), old <= c_sig;
if (LIKELY(!ok || old == c_lock))
{
return;
}
balanced_awaken(m_value, 1);
}
bool shared_cond::imp_wait(u32 slot, u64 _timeout) noexcept
{
if (slot >= 32)

View File

@ -62,53 +62,6 @@ public:
static constexpr u64 max_timeout = u64{UINT32_MAX} / 1000 * 1000000;
};
// Condition variable fused with a pseudo-mutex which is never supposed to be locked concurrently.
class unique_cond
{
enum : u32
{
c_wait = 1,
c_lock = 2,
c_sig = 3,
};
atomic_t<u32> m_value{0};
bool imp_wait(u64 _timeout) noexcept;
void imp_notify() noexcept;
public:
constexpr unique_cond() = default;
void lock() noexcept
{
// Shouldn't be locked by more than one thread concurrently
while (UNLIKELY(!m_value.compare_and_swap_test(0, c_lock)))
;
}
void unlock() noexcept
{
m_value = 0;
}
bool wait(std::unique_lock<unique_cond>& lock, u64 usec_timeout = -1) noexcept
{
AUDIT(lock.owns_lock());
AUDIT(lock.mutex() == this);
return imp_wait(usec_timeout);
}
void notify() noexcept
{
// Early exit if notification is not required
if (LIKELY(!m_value))
return;
imp_notify();
}
};
// Condition variable fused with a pseudo-mutex supporting only reader locks (up to 32 readers).
class shared_cond
{