diff options
author | Tom <tomut@yahoo.com> | 2021-03-27 14:33:31 -0600 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-03-28 20:42:21 +0200 |
commit | 7269e0f751c27fc468f0e47462cc857fea6c1f7a (patch) | |
tree | a0868ecad5d370bd5f18a5bb76a9af627f04def3 /Userland/Libraries/LibCore/Timer.h | |
parent | c3d4fbb2a58a5b46d3808e526cea78eb05e47893 (diff) | |
download | serenity-7269e0f751c27fc468f0e47462cc857fea6c1f7a.zip |
LibCore: Add Timer::create_repeating convenience method
Diffstat (limited to 'Userland/Libraries/LibCore/Timer.h')
-rw-r--r-- | Userland/Libraries/LibCore/Timer.h | 6 |
1 files changed, 6 insertions, 0 deletions
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<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)); |