2 //gcc -o efl_thread_1 efl_thread_1.c -g `pkg-config --cflags --libs elementary`
3 #include <Elementary.h>
6 static Evas_Object *win = NULL;
7 static Evas_Object *rect = NULL;
9 static pthread_t thread_id;
11 // BEGIN - code running in my custom pthread instance
14 my_thread_run(void *arg)
20 ecore_thread_main_loop_begin(); // begin critical
21 { // indented for illustration of "critical" block
24 x = 200 + (200 * sin(t));
25 y = 200 + (200 * cos(t));
26 evas_object_move(rect, x - 50, y - 50);
28 ecore_thread_main_loop_end(); // end critical
35 // END - code running in my custom pthread instance
42 if (pthread_attr_init(&attr) != 0)
43 perror("pthread_attr_init");
44 if (pthread_create(&thread_id, &attr, my_thread_run, NULL) != 0)
45 perror("pthread_create");
49 elm_main(int argc, char **argv)
53 win = elm_win_add(NULL, "efl-thread-1", ELM_WIN_BASIC);
54 elm_win_title_set(win, "EFL Thread 1");
55 elm_win_autodel_set(win, EINA_TRUE);
56 elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
57 evas_object_resize(win, 400, 400);
58 evas_object_show(win);
61 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
62 elm_win_resize_object_add(win, bg);
65 o = evas_object_rectangle_add(evas_object_evas_get(win));
66 evas_object_color_set(o, 50, 80, 180, 255);
67 evas_object_resize(o, 100, 100);
71 // create custom thread to do some "work on the side"