8 #include "ecore_private.h"
10 static Eina_Bool _ecore_job_event_handler(void *data, int type, void *ev);
11 static void _ecore_job_event_free(void *data, void *ev);
13 static int ecore_event_job_type = 0;
14 static Ecore_Event_Handler* _ecore_job_handler = NULL;
27 ecore_event_job_type = ecore_event_type_new();
28 _ecore_job_handler = ecore_event_handler_add(ecore_event_job_type, _ecore_job_event_handler, NULL);
32 _ecore_job_shutdown(void)
34 ecore_event_handler_del(_ecore_job_handler);
35 _ecore_job_handler = NULL;
39 * Add a job to the event queue.
40 * @param func The function to call when the job gets handled.
41 * @param data Data pointer to be passed to the job function when the job is
43 * @return The handle of the job. @c NULL is returned if the job could not be
45 * @ingroup Ecore_Job_Group
46 * @note Once the job has been executed, the job handle is invalid.
49 ecore_job_add(Ecore_Cb func, const void *data)
53 if (!func) return NULL;
55 job = calloc(1, sizeof(Ecore_Job));
56 if (!job) return NULL;
57 ECORE_MAGIC_SET(job, ECORE_MAGIC_JOB);
58 job->event = ecore_event_add(ecore_event_job_type, job, _ecore_job_event_free, NULL);
65 job->data = (void *)data;
70 * Delete a queued job that has not yet been executed.
71 * @param job Handle of the job to delete.
72 * @return The data pointer that was to be passed to the job.
73 * @ingroup Ecore_Job_Group
76 ecore_job_del(Ecore_Job *job)
80 if (!ECORE_MAGIC_CHECK(job, ECORE_MAGIC_JOB))
82 ECORE_MAGIC_FAIL(job, ECORE_MAGIC_JOB,
87 ECORE_MAGIC_SET(job, ECORE_MAGIC_NONE);
88 ecore_event_del(job->event);
93 _ecore_job_event_handler(void *data __UNUSED__, int type __UNUSED__, void *ev)
99 return ECORE_CALLBACK_CANCEL;
103 _ecore_job_event_free(void *data __UNUSED__, void *ev)