Thread.cpp refinement

Hide thread mutex
Safe notify() method
Other refactoring
This commit is contained in:
Nekotekina 2016-09-07 01:38:52 +03:00
parent da878c36bd
commit a5a2d43d7c
35 changed files with 532 additions and 591 deletions

View file

@ -16,7 +16,8 @@ extern u64 get_system_time();
void lv2_timer_t::on_task()
{
thread_lock lock(*this);
//thread_lock lock(*this);
LV2_LOCK;
while (state <= SYS_TIMER_STATE_RUN)
{
@ -24,7 +25,7 @@ void lv2_timer_t::on_task()
if (state == SYS_TIMER_STATE_RUN)
{
LV2_LOCK;
//LV2_LOCK;
while (get_system_time() >= expire)
{
@ -52,7 +53,7 @@ void lv2_timer_t::on_task()
continue;
}
thread_ctrl::wait_for(1000);
LV2_UNLOCK, thread_ctrl::wait_for(1000);
}
}
@ -65,7 +66,7 @@ void lv2_timer_t::on_stop()
{
// Signal thread using invalid state and join
state = -1;
this->lock_notify();
this->notify();
named_thread::on_stop();
}
@ -170,7 +171,7 @@ s32 _sys_timer_start(u32 timer_id, u64 base_time, u64 period)
timer->expire = base_time ? base_time : start_time + period;
timer->period = period;
timer->state = SYS_TIMER_STATE_RUN;
timer->lock_notify();
timer->notify();
return CELL_OK;
}