lf_queue: add iterator support

Allow range-for loop over an object returned by `pop_all()`
This commit is contained in:
Nekotekina 2019-01-03 18:18:31 +03:00
parent cfdf50dcff
commit 435f60d503
3 changed files with 154 additions and 41 deletions

View file

@ -246,9 +246,9 @@ error_code cellSysutilCheckCallback(ppu_thread& ppu)
const auto cbm = fxm::get_always<sysutil_cb_manager>();
for (auto list = cbm->registered.pop_all(); list; list = list->pop_all())
for (auto&& func : cbm->registered.pop_all())
{
if (s32 res = list->get()(ppu))
if (s32 res = func(ppu))
{
// Currently impossible
return not_an_error(res);

View file

@ -162,7 +162,7 @@ struct vdec_context final
std::unique_lock cv_lock(in_cv);
for (auto cmds = in_cmd.pop_all(); !Emu.IsStopped(); cmds ? cmds = cmds->pop_all() : 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)
{
@ -170,7 +170,7 @@ struct vdec_context final
continue;
}
if (std::get_if<vdec_start_seq_t>(&cmds->get()))
if (std::get_if<vdec_start_seq_t>(&*cmds))
{
avcodec_flush_buffers(ctx);
@ -179,7 +179,7 @@ struct vdec_context final
next_dts = 0;
cellVdec.trace("Start sequence...");
}
else if (auto* cmd = std::get_if<vdec_cmd>(&cmds->get()))
else if (auto* cmd = std::get_if<vdec_cmd>(&*cmds))
{
AVPacket packet{};
packet.pos = -1;
@ -381,7 +381,7 @@ struct vdec_context final
in_cv.wait(cv_lock, 1000);
}
}
else if (auto* frc = std::get_if<CellVdecFrameRate>(&cmds->get()))
else if (auto* frc = std::get_if<CellVdecFrameRate>(&*cmds))
{
frc_set = *frc;
}