1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-22 10:42:36 +01:00

Rename cond_one to unique_cond

Remove redundant in_cv in cellVdec
This commit is contained in:
Nekotekina 2019-06-02 23:21:13 +03:00
parent 0333942795
commit 31994dd3b2
3 changed files with 8 additions and 15 deletions

View File

@ -148,7 +148,7 @@ bool notifier::wait(u64 usec_timeout)
return res; return res;
} }
bool cond_one::imp_wait(u64 _timeout) noexcept bool unique_cond::imp_wait(u64 _timeout) noexcept
{ {
// State transition: c_sig -> c_lock \ c_lock -> c_wait // State transition: c_sig -> c_lock \ c_lock -> c_wait
const u32 _old = m_value.fetch_sub(1); const u32 _old = m_value.fetch_sub(1);
@ -173,7 +173,7 @@ bool cond_one::imp_wait(u64 _timeout) noexcept
}); });
} }
void cond_one::imp_notify() noexcept void unique_cond::imp_notify() noexcept
{ {
auto [old, ok] = m_value.fetch_op([](u32& v) auto [old, ok] = m_value.fetch_op([](u32& v)
{ {

View File

@ -64,7 +64,7 @@ public:
static constexpr u64 max_timeout = u64{UINT32_MAX} / 1000 * 1000000; static constexpr u64 max_timeout = u64{UINT32_MAX} / 1000 * 1000000;
}; };
// Pair of a fake shared mutex (only limited shared locking) and a condition variable // Pair of a fake shared mutex (only limited shared locking) and a condition variable. Obsolete.
class notifier class notifier
{ {
atomic_t<u32> m_counter{0}; atomic_t<u32> m_counter{0};
@ -129,7 +129,8 @@ public:
static constexpr u32 max_readers = 0x7f; static constexpr u32 max_readers = 0x7f;
}; };
class cond_one // Condition variable fused with a pseudo-mutex which is never supposed to be locked concurrently.
class unique_cond
{ {
enum : u32 enum : u32
{ {
@ -144,7 +145,7 @@ class cond_one
void imp_notify() noexcept; void imp_notify() noexcept;
public: public:
constexpr cond_one() = default; constexpr unique_cond() = default;
void lock() noexcept void lock() noexcept
{ {
@ -158,7 +159,7 @@ public:
m_value = 0; m_value = 0;
} }
bool wait(std::unique_lock<cond_one>& lock, u64 usec_timeout = -1) noexcept bool wait(std::unique_lock<unique_cond>& lock, u64 usec_timeout = -1) noexcept
{ {
AUDIT(lock.owns_lock()); AUDIT(lock.owns_lock());
AUDIT(lock.mutex() == this); AUDIT(lock.mutex() == this);

View File

@ -90,7 +90,6 @@ struct vdec_context final
atomic_t<u32> au_count{0}; atomic_t<u32> au_count{0};
cond_one in_cv;
lf_queue<std::variant<vdec_start_seq_t, vdec_close_t, vdec_cmd, CellVdecFrameRate>> in_cmd; lf_queue<std::variant<vdec_start_seq_t, vdec_close_t, vdec_cmd, CellVdecFrameRate>> in_cmd;
vdec_context(s32 type, u32 profile, u32 addr, u32 size, vm::ptr<CellVdecCbMsg> func, u32 arg) vdec_context(s32 type, u32 profile, u32 addr, u32 size, vm::ptr<CellVdecCbMsg> func, u32 arg)
@ -161,13 +160,11 @@ struct vdec_context final
{ {
ppu_tid = ppu.id; ppu_tid = ppu.id;
std::unique_lock cv_lock(in_cv);
for (auto cmds = in_cmd.pop_all(); !Emu.IsStopped(); cmds ? cmds.pop_front() : cmds = in_cmd.pop_all()) for (auto cmds = in_cmd.pop_all(); !Emu.IsStopped(); cmds ? cmds.pop_front() : cmds = in_cmd.pop_all())
{ {
if (!cmds) if (!cmds)
{ {
in_cv.wait(cv_lock, 1000); in_cmd.wait(1000);
continue; continue;
} }
@ -498,7 +495,6 @@ s32 cellVdecClose(ppu_thread& ppu, u32 handle)
lv2_obj::sleep(ppu); lv2_obj::sleep(ppu);
vdec->out_max = 0; vdec->out_max = 0;
vdec->in_cmd.push(vdec_close); vdec->in_cmd.push(vdec_close);
vdec->in_cv.notify();
while (!atomic_storage<u64>::load(vdec->ppu_tid)) while (!atomic_storage<u64>::load(vdec->ppu_tid))
{ {
@ -522,7 +518,6 @@ s32 cellVdecStartSeq(u32 handle)
} }
vdec->in_cmd.push(vdec_start_seq); vdec->in_cmd.push(vdec_start_seq);
vdec->in_cv.notify();
return CELL_OK; return CELL_OK;
} }
@ -538,7 +533,6 @@ s32 cellVdecEndSeq(u32 handle)
} }
vdec->in_cmd.push(vdec_cmd{-1}); vdec->in_cmd.push(vdec_cmd{-1});
vdec->in_cv.notify();
return CELL_OK; return CELL_OK;
} }
@ -560,7 +554,6 @@ s32 cellVdecDecodeAu(u32 handle, CellVdecDecodeMode mode, vm::cptr<CellVdecAuInf
// TODO: check info // TODO: check info
vdec->in_cmd.push(vdec_cmd{mode, *auInfo}); vdec->in_cmd.push(vdec_cmd{mode, *auInfo});
vdec->in_cv.notify();
return CELL_OK; return CELL_OK;
} }
@ -911,7 +904,6 @@ s32 cellVdecSetFrameRate(u32 handle, CellVdecFrameRate frc)
// TODO: check frc value // TODO: check frc value
vdec->in_cmd.push(frc); vdec->in_cmd.push(frc);
vdec->in_cv.notify();
return CELL_OK; return CELL_OK;
} }