1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 06:57:45 +00:00

LibCore: Add Timer::create_repeating convenience method

This commit is contained in:
Tom 2021-03-27 14:33:31 -06:00 committed by Andreas Kling
parent c3d4fbb2a5
commit 7269e0f751

View file

@ -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));