1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-05 08:27:35 +00:00

LibCore: Add CTimer::restart() and make set_interval() take effect soon.

This commit is contained in:
Andreas Kling 2019-04-18 04:38:04 +02:00
parent a747a10eab
commit d73ed74d1c
2 changed files with 23 additions and 1 deletions

View file

@ -30,6 +30,13 @@ void CTimer::start(int interval)
m_active = true;
}
void CTimer::restart(int interval)
{
if (m_active)
stop();
start(interval);
}
void CTimer::stop()
{
if (!m_active)
@ -42,6 +49,13 @@ void CTimer::timer_event(CTimerEvent&)
{
if (m_single_shot)
stop();
else {
if (m_interval_dirty) {
stop();
start(m_interval);
}
}
if (on_timeout)
on_timeout();
}