diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/test.c | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/test/test.c b/test/test.c new file mode 100644 index 0000000..bf1654b --- /dev/null +++ b/test/test.c @@ -0,0 +1,63 @@ +#include <aki/common.h> +#include <aki/thread.h> +#include <aki/line_processor.h> +#include <aki/timer.h> + +aki_thread_result AKI_THREADCALL test_thread(void *userdata) +{ + (void)userdata; + for (u32 i = 0; i < 10; i++) { + printf("Yo\n"); + aki_thread_sleep(1.0); + } + return 0; +} + +static struct aki_event_loop loop; + +static void line_callback(void *userdata, str *line) +{ + (void)userdata; + al_printf("%.*s\n", AL_STR_PRINTF(line)); + if (al_str_eq(line, al_str_c("quit"))) aki_event_loop_break(&loop); +} + +static void timer_callback(void *userdata, struct aki_timer *timer) +{ + printf("Yo\n"); + aki_timer_again(timer); +} + +s32 main(void) +{ + aki_common_init(); + + aki_event_loop_init(&loop); + + struct aki_timer timer; + aki_timer_init(&timer, &loop, 1.0, timer_callback, NULL); + aki_timer_again(&timer); + + /* + struct aki_thread thread; + aki_thread_create(&thread, test_thread, NULL); + aki_thread_join(&thread); + */ + +#ifndef _WIN32 + /* + struct aki_line_processor pro; + pro.callback = line_callback; + pro.userdata = NULL; + aki_line_processor_init(&pro, al_str_c("\n")); + aki_line_processor_open_fd(&pro, STDIN_FILENO); + aki_line_processor_run(&pro, &loop); + */ +#endif + + aki_event_loop_run(&loop); + + aki_common_close(); + + return 0; +} |