apps: Use os::Timer instead of os::EventLoop::register_timer

This commit is contained in:
apio 2024-01-05 22:18:12 +01:00
parent a9c339939a
commit 7f6863c093
Signed by: apio
GPG Key ID: B8A7D06E42258954
2 changed files with 7 additions and 4 deletions

View File

@ -1,3 +1,4 @@
#include <os/Timer.h>
#include <time.h> #include <time.h>
#include <ui/App.h> #include <ui/App.h>
#include <ui/Label.h> #include <ui/Label.h>
@ -14,8 +15,6 @@ void update_time()
g_label->set_text(StringView { buf }); g_label->set_text(StringView { buf });
os::EventLoop::the().register_timer(1000, update_time);
ui::App::the().main_window()->draw(); ui::App::the().main_window()->draw();
} }
@ -38,5 +37,7 @@ Result<int> luna_main(int argc, char** argv)
update_time(); update_time();
auto timer = TRY(os::Timer::create_repeating(1000, update_time));
return app.run(); return app.run();
} }

View File

@ -2,6 +2,7 @@
#include <fcntl.h> #include <fcntl.h>
#include <luna/Heap.h> #include <luna/Heap.h>
#include <os/ArgumentParser.h> #include <os/ArgumentParser.h>
#include <os/Timer.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <time.h> #include <time.h>
@ -105,7 +106,6 @@ static void update()
{ {
next_generation(); next_generation();
draw_cells(); draw_cells();
os::EventLoop::the().register_timer(100, update);
} }
Result<int> luna_main(int argc, char** argv) Result<int> luna_main(int argc, char** argv)
@ -119,7 +119,9 @@ Result<int> luna_main(int argc, char** argv)
TRY(fill_cells()); TRY(fill_cells());
os::EventLoop::the().register_timer(100, update); update();
auto timer = TRY(os::Timer::create_repeating(100, update));
return app.run(); return app.run();
} }