Beispiel #1
0
static void
em_del(void *video)
{
   Emotion_Gstreamer_Video *ev = video;

   if (ev->threads)
     {
        Ecore_Thread *t;

        EINA_LIST_FREE(ev->threads, t)
          ecore_thread_cancel(t);

        ev->delete_me = EINA_TRUE;
        return;
     }

   if (ev->in != ev->out)
     {
        ev->delete_me = EINA_TRUE;
        return;
     }

   em_cleanup(ev);

   free(ev);
}
EAPI_MAIN int
elm_main(int argc, char **argv)
{
   Evas_Object *o;

   elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);

   win = elm_win_util_standard_add("efl-thread-5", "EFL Thread 5");
   evas_object_smart_callback_add(win, "delete,request", del, NULL);

   o = evas_object_rectangle_add(evas_object_evas_get(win));
   evas_object_color_set(o, 50, 80, 180, 255);
   evas_object_resize(o, 100, 100);
   evas_object_show(o);
   evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN, down, NULL);
   rect = o;

   // explicitly create ecore thread to do some "work on the side" and pass
   // in NULL as data ptr to callbacks and true at the end means to actually
   // make a new thread and not use the thread pool (there is a thread pool
   // with as many thread workers as there are cpu's so this means you do not
   // overload the cpu's with more work than you actually have processing
   // units *IF* your threads do actually spend their time doing actual
   // heavy computation)
   thr = ecore_thread_feedback_run(th_do, th_feedback, th_end, th_cancel,
                                   NULL, EINA_TRUE);

   evas_object_resize(win, 400, 400);
   evas_object_show(win);

   elm_run();
   if (thr) ecore_thread_cancel(thr);

   return 0;
}
// on window delete - cancel thread then delete window and exit mainloop
static void
del(void *data, Evas_Object *obj, void *event_info)
{
   if (thr) ecore_thread_cancel(thr);
   thr = NULL;
   evas_object_del(obj);
   elm_exit();
}
Beispiel #4
0
static void
em_file_close(void *video)
{
   Emotion_Gstreamer_Video *ev;

   ev = (Emotion_Gstreamer_Video *)video;
   if (!ev)
     return;

   if (ev->threads)
     {
        Ecore_Thread *t;

        EINA_LIST_FREE(ev->threads, t)
          ecore_thread_cancel(t);
     }

   em_cleanup(ev);

   ev->pipeline_parsed = EINA_FALSE;
   ev->play_started = 0;
}
Beispiel #5
0
// just test cancelling the thread worker
static void
down(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
   ecore_thread_cancel(thr);
}
Beispiel #6
0
EAPI int
eio_shutdown(void)
{
   Eio_File_Direct_Info *info;
   Eio_File_Char *cin;
   Eio_Progress *pg;
   Eio_File_Associate *asso;
   Eio_File *f;
   Eina_List *l;

   if (_eio_init_count <= 0)
     {
        ERR("Init count not greater than 0 in shutdown.");
        return 0;
     }
   if (--_eio_init_count != 0)
     return _eio_init_count;

   eina_log_timing(_eio_log_dom_global,
                   EINA_LOG_STATE_START,
                   EINA_LOG_STATE_SHUTDOWN);

   efl_del(io_manager);
   io_manager = NULL;

   EINA_LIST_FOREACH(tracked_thread, l, f)
     ecore_thread_cancel(f->thread);

   EINA_LIST_FREE(tracked_thread, f)
     {
        if (!ecore_thread_wait(f->thread, 0.5))
          CRI("We couldn't terminate in less than 30s some pending IO. This can led to some crash.");
     }

   efreet_mime_shutdown();

   eio_monitor_shutdown();

   eina_condition_free(&(memory_pool_cond));
   eina_lock_free(&(memory_pool_mutex));
   eina_spinlock_free(&(memory_pool_lock));

   eina_lock_free(&(direct_info_pool.lock));
   eina_lock_free(&(progress_pool.lock));
   eina_lock_free(&(char_pool.lock));
   eina_lock_free(&(associate_pool.lock));

   /* Cleanup pool */
   EINA_TRASH_CLEAN(&progress_pool.trash, pg)
     free(pg);
   progress_pool.count = 0;

   EINA_TRASH_CLEAN(&direct_info_pool.trash, info)
     free(info);
   direct_info_pool.count = 0;

   EINA_TRASH_CLEAN(&char_pool.trash, cin)
     free(cin);
   char_pool.count = 0;

   EINA_TRASH_CLEAN(&associate_pool.trash, asso)
     free(asso);
   associate_pool.count = 0;

   ecore_shutdown();
   eina_log_domain_unregister(_eio_log_dom_global);
   _eio_log_dom_global = -1;
   eina_shutdown();

   return _eio_init_count;
}