This is the same as EFL Threading example 4 but now uses the ecore_thread infrastructure to have a running worker thread that feeds results back to the mainloop and can easily be cancelled.
This saves some code in the application and makes for fewer problem spots if you forget a mutex.
EFL Threading example 6
#include <Elementary.h>
struct info
{
double x, y;
};
static void
{
double t = 0.0;
for (;;)
{
struct info *inf = malloc(sizeof(struct info));
if (inf)
{
inf->x = 200 + (200 * sin(t));
inf->y = 200 + (200 * cos(t));
}
usleep(1000);
t += 0.02;
}
}
static void
th_feedback(
void *data EINA_UNUSED,
Ecore_Thread *th EINA_UNUSED,
void *msg)
{
struct info *inf = msg;
free(inf);
}
static void th_end(
void *data EINA_UNUSED,
Ecore_Thread *th EINA_UNUSED) { printf(
"thread ended\n"); }
static void th_cancel(
void *data EINA_UNUSED,
Ecore_Thread *th EINA_UNUSED) { printf(
"thread cancelled\n"); }
static void
down(
void *data EINA_UNUSED,
Evas *e EINA_UNUSED,
Evas_Object *obj EINA_UNUSED,
void *event_info EINA_UNUSED)
{
thr = NULL;
}
static void
del(
void *data EINA_UNUSED,
Evas_Object *obj,
void *event_info EINA_UNUSED)
{
thr = NULL;
}
EAPI_MAIN int
elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
{
rect = o;
return 0;
}