mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-31 21:29:06 +00:00
LibCore: Add a convenience constructor for CTimer.
new CTimer(250, [] { thing_to_do_every_250_msec(); });
This commit is contained in:
parent
2af729a58a
commit
a3e8fc3d9c
Notes:
sideshowbarker
2024-07-19 14:43:16 +09:00
Author: https://github.com/awesomekling
Commit: a3e8fc3d9c
3 changed files with 11 additions and 4 deletions
|
@ -5,6 +5,13 @@ CTimer::CTimer(CObject* parent)
|
|||
{
|
||||
}
|
||||
|
||||
CTimer::CTimer(int interval, Function<void()>&& timeout_handler, CObject* parent)
|
||||
: CObject(parent)
|
||||
, on_timeout(move(timeout_handler))
|
||||
{
|
||||
start(interval);
|
||||
}
|
||||
|
||||
CTimer::~CTimer()
|
||||
{
|
||||
}
|
||||
|
@ -18,6 +25,7 @@ void CTimer::start(int interval)
|
|||
{
|
||||
if (m_active)
|
||||
return;
|
||||
m_interval = interval;
|
||||
start_timer(interval);
|
||||
m_active = true;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue