mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 14:17:36 +00:00
LibCore: Add Timer::create_repeating convenience method
This commit is contained in:
parent
c3d4fbb2a5
commit
7269e0f751
1 changed files with 6 additions and 0 deletions
|
@ -35,6 +35,12 @@ class Timer final : public Object {
|
|||
C_OBJECT(Timer);
|
||||
|
||||
public:
|
||||
static NonnullRefPtr<Timer> create_repeating(int interval, Function<void()>&& timeout_handler, Object* parent = nullptr)
|
||||
{
|
||||
auto timer = adopt(*new Timer(interval, move(timeout_handler), parent));
|
||||
timer->stop();
|
||||
return timer;
|
||||
}
|
||||
static NonnullRefPtr<Timer> create_single_shot(int interval, Function<void()>&& timeout_handler, Object* parent = nullptr)
|
||||
{
|
||||
auto timer = adopt(*new Timer(interval, move(timeout_handler), parent));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue