diff options
Diffstat (limited to '')
-rw-r--r-- | libraries/ecore/src/examples/ecore_job_example.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/libraries/ecore/src/examples/ecore_job_example.c b/libraries/ecore/src/examples/ecore_job_example.c new file mode 100644 index 0000000..1d28b7b --- /dev/null +++ b/libraries/ecore/src/examples/ecore_job_example.c | |||
@@ -0,0 +1,48 @@ | |||
1 | #include <Ecore.h> | ||
2 | #include <unistd.h> | ||
3 | |||
4 | static void | ||
5 | _job_print_cb(void *data) | ||
6 | { | ||
7 | char *str = data; | ||
8 | |||
9 | printf("%s\n", str); | ||
10 | } | ||
11 | |||
12 | static void | ||
13 | _job_quit_cb(void *data) | ||
14 | { | ||
15 | ecore_main_loop_quit(); | ||
16 | } | ||
17 | |||
18 | int main(int argc, char **argv) | ||
19 | { | ||
20 | Ecore_Job *job1, *job2, *job3, *job_quit; | ||
21 | char *str1 = "Job 1 started."; | ||
22 | char *str2 = "Job 2 started."; | ||
23 | char *str3 = "Job 3 started."; | ||
24 | |||
25 | if (!ecore_init()) | ||
26 | { | ||
27 | printf("ERROR: Cannot init Ecore!\n"); | ||
28 | return -1; | ||
29 | } | ||
30 | |||
31 | job1 = ecore_job_add(_job_print_cb, str1); | ||
32 | job2 = ecore_job_add(_job_print_cb, str2); | ||
33 | job3 = ecore_job_add(_job_print_cb, str3); | ||
34 | |||
35 | job_quit = ecore_job_add(_job_quit_cb, NULL); | ||
36 | printf("Created jobs 1, 2, 3 and quit.\n"); | ||
37 | |||
38 | if (job2) | ||
39 | { | ||
40 | char *str; | ||
41 | str = ecore_job_del(job2); | ||
42 | job2 = NULL; | ||
43 | printf("Deleted job 2. Its data was: \"%s\"\n", str); | ||
44 | } | ||
45 | |||
46 | ecore_main_loop_begin(); | ||
47 | ecore_shutdown(); | ||
48 | } | ||