From b00d78697723eb3930a40125c02d328548946206 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Sat, 5 Sep 2020 23:34:05 +0200 Subject: Improved scheduler --- apps/mandelbrot.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'apps') diff --git a/apps/mandelbrot.c b/apps/mandelbrot.c index 6eef9ef..a2be040 100644 --- a/apps/mandelbrot.c +++ b/apps/mandelbrot.c @@ -42,6 +42,9 @@ void draw_mandelbrot(struct window *win, int resolution) rand() << 16 | rand() << 8 | rand() | 0xff000000); else draw_pixel(win, col, row, 0xff000000); + + if (row % 50 == 0 && col == 0) + gui_redraw(); } } gui_redraw(); @@ -54,17 +57,11 @@ int main() struct window *win = gui_new_window(WF_DEFAULT); gui_fill(win, BG_COLOR); - event_register(EVENT_KEYBOARD); - int resolution = 0; - struct message *msg; + draw_mandelbrot(win, 50); + while (1) { - if (!(msg = msg_receive())) { - yield(); - continue; - } - if (msg->type == EVENT_KEYBOARD && ((struct event_keyboard *)msg->data)->press) - draw_mandelbrot(win, ++resolution); + yield(); }; return 0; -- cgit v1.2.3