mirror of https://github.com/RPCS3/rpcs3.git
parent
34a0c3f488
commit
5a73943be6
|
@ -16,11 +16,9 @@ extern u64 get_guest_system_time();
|
||||||
|
|
||||||
void lv2_timer_context::operator()()
|
void lv2_timer_context::operator()()
|
||||||
{
|
{
|
||||||
while (!Emu.IsStopped())
|
while (thread_ctrl::state() != thread_state::aborting)
|
||||||
{
|
{
|
||||||
const u32 _state = state;
|
if (state == SYS_TIMER_STATE_RUN)
|
||||||
|
|
||||||
if (_state == SYS_TIMER_STATE_RUN)
|
|
||||||
{
|
{
|
||||||
const u64 _now = get_guest_system_time();
|
const u64 _now = get_guest_system_time();
|
||||||
const u64 next = expire;
|
const u64 next = expire;
|
||||||
|
@ -42,22 +40,17 @@ void lv2_timer_context::operator()()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stop after oneshot
|
// Stop after oneshot
|
||||||
state.compare_and_swap_test(SYS_TIMER_STATE_RUN, SYS_TIMER_STATE_STOP);
|
state.release(SYS_TIMER_STATE_STOP);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: use single global dedicated thread for busy waiting, no timer threads
|
// TODO: use single global dedicated thread for busy waiting, no timer threads
|
||||||
lv2_obj::wait_timeout(next - _now);
|
lv2_obj::wait_timeout(next - _now);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
else if (_state == SYS_TIMER_STATE_STOP)
|
|
||||||
{
|
|
||||||
thread_ctrl::wait_for(10000);
|
thread_ctrl::wait_for(10000);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
error_code sys_timer_create(ppu_thread& ppu, vm::ptr<u32> timer_id)
|
error_code sys_timer_create(ppu_thread& ppu, vm::ptr<u32> timer_id)
|
||||||
|
@ -83,13 +76,12 @@ error_code sys_timer_destroy(ppu_thread& ppu, u32 timer_id)
|
||||||
|
|
||||||
const auto timer = idm::withdraw<lv2_obj, lv2_timer>(timer_id, [&](lv2_timer& timer) -> CellError
|
const auto timer = idm::withdraw<lv2_obj, lv2_timer>(timer_id, [&](lv2_timer& timer) -> CellError
|
||||||
{
|
{
|
||||||
std::lock_guard lock(timer.mutex);
|
if (std::shared_lock lock(timer.mutex); !timer.port.expired())
|
||||||
|
|
||||||
if (!timer.port.expired())
|
|
||||||
{
|
{
|
||||||
return CELL_EISCONN;
|
return CELL_EISCONN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
timer = thread_state::aborting;
|
||||||
return {};
|
return {};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue