static void _eio_ls_xattr_heavy(void *data, Ecore_Thread *thread) { Eio_File_Char_Ls *async = data; Eina_Iterator *it; const char *tmp; it = eina_xattr_ls(async->ls.directory); if (!it) return ; EINA_ITERATOR_FOREACH(it, tmp) { Eina_Bool filter = EINA_TRUE; if (async->filter_cb) { filter = async->filter_cb((void*) async->ls.common.data, &async->ls.common, tmp); } if (filter) ecore_thread_feedback(thread, eina_stringshare_add(tmp)); if (ecore_thread_check(thread)) break; }
// BEGIN - code running in my custom thread instance // static void th_do(void *data, Ecore_Thread *th) { double t = 0.0; // inside our "do" function for the ecore thread, lets do the real work for (;;) { struct info *inf = malloc(sizeof(struct info)); if (inf) { inf->x = 200 + (200 * sin(t)); inf->y = 200 + (200 * cos(t)); // now we have recorded the timepoint we pass it as feedback // back to the mainloop. it will free it when done ecore_thread_feedback(th, inf); } // and sleep and loop usleep(1000); t += 0.02; // in case someone has asked us to cancel - then cancel this loop // co-operatively (cancelling is co-operative) if (ecore_thread_check(th)) break; } }
static void _eio_file_heavy(void *data, Ecore_Thread *thread) { Eio_File_Char_Ls *async = data; Eina_Iterator *ls; const char *file; Eina_List *pack = NULL; double start; ls = eina_file_ls(async->ls.directory); if (!ls) { eio_file_thread_error(&async->ls.common, thread); return; } eio_file_container_set(&async->ls.common, eina_iterator_container_get(ls)); start = ecore_time_get(); EINA_ITERATOR_FOREACH(ls, file) { Eina_Bool filter = EINA_TRUE; if (async->filter_cb) { filter = async->filter_cb((void*) async->ls.common.data, &async->ls.common, file); } if (filter) { Eio_File_Char *send_fc; send_fc = eio_char_malloc(); if (!send_fc) goto on_error; send_fc->filename = file; send_fc->associated = async->ls.common.worker.associated; async->ls.common.worker.associated = NULL; pack = eina_list_append(pack, send_fc); } else { on_error: eina_stringshare_del(file); if (async->ls.common.worker.associated) { eina_hash_free(async->ls.common.worker.associated); async->ls.common.worker.associated = NULL; } } pack = eio_pack_send(thread, pack, &start); if (ecore_thread_check(thread)) break; }