From 7f6863c0938374d94d805ec431c83564a39b09fb Mon Sep 17 00:00:00 2001 From: apio Date: Fri, 5 Jan 2024 22:18:12 +0100 Subject: [PATCH] apps: Use os::Timer instead of os::EventLoop::register_timer --- apps/clock.cpp | 5 +++-- apps/gol.cpp | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/apps/clock.cpp b/apps/clock.cpp index 080958b3..31951308 100644 --- a/apps/clock.cpp +++ b/apps/clock.cpp @@ -1,3 +1,4 @@ +#include #include #include #include @@ -14,8 +15,6 @@ void update_time() g_label->set_text(StringView { buf }); - os::EventLoop::the().register_timer(1000, update_time); - ui::App::the().main_window()->draw(); } @@ -38,5 +37,7 @@ Result luna_main(int argc, char** argv) update_time(); + auto timer = TRY(os::Timer::create_repeating(1000, update_time)); + return app.run(); } diff --git a/apps/gol.cpp b/apps/gol.cpp index 08e0324c..2957a615 100644 --- a/apps/gol.cpp +++ b/apps/gol.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include #include #include @@ -105,7 +106,6 @@ static void update() { next_generation(); draw_cells(); - os::EventLoop::the().register_timer(100, update); } Result luna_main(int argc, char** argv) @@ -119,7 +119,9 @@ Result luna_main(int argc, char** argv) TRY(fill_cells()); - os::EventLoop::the().register_timer(100, update); + update(); + + auto timer = TRY(os::Timer::create_repeating(100, update)); return app.run(); }