From 7269e0f751c27fc468f0e47462cc857fea6c1f7a Mon Sep 17 00:00:00 2001 From: Tom Date: Sat, 27 Mar 2021 14:33:31 -0600 Subject: [PATCH] LibCore: Add Timer::create_repeating convenience method --- Userland/Libraries/LibCore/Timer.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Userland/Libraries/LibCore/Timer.h b/Userland/Libraries/LibCore/Timer.h index 04f41e39a0..d9add660bc 100644 --- a/Userland/Libraries/LibCore/Timer.h +++ b/Userland/Libraries/LibCore/Timer.h @@ -35,6 +35,12 @@ class Timer final : public Object { C_OBJECT(Timer); public: + static NonnullRefPtr create_repeating(int interval, Function&& timeout_handler, Object* parent = nullptr) + { + auto timer = adopt(*new Timer(interval, move(timeout_handler), parent)); + timer->stop(); + return timer; + } static NonnullRefPtr create_single_shot(int interval, Function&& timeout_handler, Object* parent = nullptr) { auto timer = adopt(*new Timer(interval, move(timeout_handler), parent));