/src/test/main_loop_test.c

http://ftk.googlecode.com/ · C · 45 lines · 34 code · 11 blank · 0 comment · 0 complexity · cf1148f0f5385e69dcea23e9bc9699d6 MD5 · raw file

  1. #include "ftk.h"
  2. #include "ftk_globals.h"
  3. #include "ftk_main_loop.h"
  4. #include "ftk_source_idle.h"
  5. #include "ftk_source_timer.h"
  6. Ret timeout_quit(void* user_data)
  7. {
  8. ftk_quit();
  9. printf("%s:%d\n", __func__, __LINE__);
  10. return RET_REMOVE;
  11. }
  12. Ret timeout_repeat(void* user_data)
  13. {
  14. printf("%s:%d\n", __func__, __LINE__);
  15. return RET_OK;
  16. }
  17. Ret idle(void* user_data)
  18. {
  19. printf("%s:%d\n", __func__, __LINE__);
  20. return RET_REMOVE;
  21. }
  22. int main(int argc, char* argv[])
  23. {
  24. FtkSource* source = NULL;
  25. ftk_init(argc, argv);
  26. source = ftk_source_idle_create(idle, NULL);
  27. ftk_main_loop_add_source(ftk_default_main_loop(), source);
  28. source = ftk_source_timer_create(1000, timeout_repeat, NULL);
  29. ftk_main_loop_add_source(ftk_default_main_loop(), source);
  30. source = ftk_source_timer_create(5000, timeout_quit, NULL);
  31. ftk_main_loop_add_source(ftk_default_main_loop(), source);
  32. ftk_run();
  33. return 0;
  34. }