1 #include <Elementary.h>
4 static Evas_Object *win = NULL;
5 static Evas_Object *rect = NULL;
12 static void my_thread_mainloop_code(void *data);
14 static pthread_t thread_id;
16 // BEGIN - code running in my custom pthread instance
19 my_thread_run(void *arg)
23 // inside the pthread function lets loop forever incrimenting a time point
26 struct info *inf = malloc(sizeof(struct info));
30 inf->x = 200 + (200 * sin(t));
31 inf->y = 200 + (200 * cos(t));
32 // now call a function in the mainloop and pass it our allocated
33 // data that it will free when it gets it
34 ecore_main_loop_thread_safe_call_async
35 (my_thread_mainloop_code, inf);
44 // END - code running in my custom pthread instance
50 if (pthread_attr_init(&attr) != 0)
51 perror("pthread_attr_init");
52 if (pthread_create(&thread_id, &attr, my_thread_run, NULL) != 0)
53 perror("pthread_create");
57 my_thread_mainloop_code(void *data)
59 struct info *inf = data;
60 evas_object_move(rect, inf->x - 50, inf->y - 50);
65 elm_main(int argc, char **argv)
69 win = elm_win_add(NULL, "efl-thread-3", ELM_WIN_BASIC);
70 elm_win_title_set(win, "EFL Thread 3");
71 evas_object_resize(win, 400, 400);
72 evas_object_show(win);
75 elm_win_resize_object_add(win, bg);
76 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
79 o = evas_object_rectangle_add(evas_object_evas_get(win));
80 evas_object_color_set(o, 50, 80, 180, 255);
81 evas_object_resize(o, 100, 100);
85 // create custom thread to do some "work on the side"