PageRenderTime 25ms CodeModel.GetById 21ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/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
 7Ret timeout_quit(void* user_data)
 8{
 9	ftk_quit();
10
11	printf("%s:%d\n", __func__, __LINE__);
12	return RET_REMOVE;
13}
14
15Ret timeout_repeat(void* user_data)
16{
17	printf("%s:%d\n", __func__, __LINE__);
18	return RET_OK;
19}
20
21Ret idle(void* user_data)
22{
23	printf("%s:%d\n", __func__, __LINE__);
24	return RET_REMOVE;
25}
26
27int main(int argc, char* argv[])
28{
29	FtkSource* source = NULL;
30	ftk_init(argc, argv);
31
32	source = ftk_source_idle_create(idle, NULL);
33	ftk_main_loop_add_source(ftk_default_main_loop(), source);
34
35	source = ftk_source_timer_create(1000, timeout_repeat, NULL);
36	ftk_main_loop_add_source(ftk_default_main_loop(), source);
37
38	source = ftk_source_timer_create(5000, timeout_quit, NULL);
39	ftk_main_loop_add_source(ftk_default_main_loop(), source);
40
41	ftk_run();
42
43	return 0;
44}
45