*/
typedef Eina_Bool (*Ecore_Event_Handler_Cb) (void *data, int type, void *event);
/**
- * @typedef Ecore_Thread_Heavy_Cb Ecore_Thread_Heavy_Cb
- * A callback used to run cpu intensive or blocking I/O operations.
+ * @typedef Ecore_Thread_Cb Ecore_Thread_Cb
+ * A callback used by Ecore_Thread helper.
*/
- typedef void (*Ecore_Thread_Heavy_Cb) (Ecore_Thread *thread, void *data);
+ typedef void (*Ecore_Thread_Cb) (void *data, Ecore_Thread *thread);
/**
* @typedef Ecore_Thread_Notify_Cb Ecore_Thread_Notify_Cb
* A callback used by the main loop to receive data sent by an @ref Ecore_Thread_Group.
*/
- typedef void (*Ecore_Thread_Notify_Cb) (Ecore_Thread *thread, void *msg_data, void *data);
+ typedef void (*Ecore_Thread_Notify_Cb) (void *data, Ecore_Thread *thread, void *msg_data);
/**
* @typedef Ecore_Task_Cb Ecore_Task_Cb
* A callback run for a task (timer, idler, poller, animater, etc)
* @{
*/
- EAPI Ecore_Thread *ecore_thread_run(Ecore_Thread_Heavy_Cb func_blocking,
- Ecore_Cb func_end,
- Ecore_Cb func_cancel,
+ EAPI Ecore_Thread *ecore_thread_run(Ecore_Thread_Cb func_blocking,
+ Ecore_Thread_Cb func_end,
+ Ecore_Thread_Cb func_cancel,
const void *data);
- EAPI Ecore_Thread *ecore_thread_feedback_run(Ecore_Thread_Heavy_Cb func_heavy,
+ EAPI Ecore_Thread *ecore_thread_feedback_run(Ecore_Thread_Cb func_heavy,
Ecore_Thread_Notify_Cb func_notify,
- Ecore_Cb func_end,
- Ecore_Cb func_cancel,
+ Ecore_Thread_Cb func_end,
+ Ecore_Thread_Cb func_cancel,
const void *data,
Eina_Bool try_no_queue);
EAPI Eina_Bool ecore_thread_cancel(Ecore_Thread *thread);
{
union {
struct {
- Ecore_Thread_Heavy_Cb func_blocking;
+ Ecore_Thread_Cb func_blocking;
} short_run;
struct {
- Ecore_Thread_Heavy_Cb func_heavy;
+ Ecore_Thread_Cb func_heavy;
Ecore_Thread_Notify_Cb func_notify;
Ecore_Pipe *notify;
} feedback_run;
} u;
- Ecore_Cb func_cancel;
- Ecore_Cb func_end;
+ Ecore_Thread_Cb func_cancel;
+ Ecore_Thread_Cb func_end;
#ifdef EFL_HAVE_PTHREAD
pthread_t self;
Eina_Hash *hash;
}
static void
-_ecore_thread_end(Ecore_Pthread_Data *pth)
+_ecore_thread_end(Ecore_Pthread_Data *pth, __UNUSED__ Ecore_Thread *work)
{
Ecore_Pipe *p;
if (work->cancel)
{
if (work->func_cancel)
- work->func_cancel((void *) work->data);
+ work->func_cancel((void *) work->data, (Ecore_Thread *) work);
}
else
{
if (work->func_end)
- work->func_end((void *) work->data);
+ work->func_end((void *) work->data, (Ecore_Thread *) work);
}
if (work->feedback_run)
work->u.feedback_run.received++;
if (work->u.feedback_run.func_notify)
- work->u.feedback_run.func_notify((Ecore_Thread *) work, user_data, (void *) work->data);
+ work->u.feedback_run.func_notify((void *) work->data, (Ecore_Thread *) work, user_data);
/* Force reading all notify event before killing the thread */
if (work->kill && work->u.feedback_run.send == work->u.feedback_run.received)
pthread_mutex_unlock(&_ecore_pending_job_threads_mutex);
if (!work->cancel)
- work->u.short_run.func_blocking((Ecore_Thread*) work, (void *) work->data);
+ work->u.short_run.func_blocking((void *) work->data, (Ecore_Thread*) work);
ecore_pipe_write(end_pipe, &work, sizeof (Ecore_Pthread_Worker *));
}
work->self = thread;
if (!work->cancel)
- work->u.feedback_run.func_heavy((Ecore_Thread *) work, (void *) work->data);
+ work->u.feedback_run.func_heavy((void *) work->data, (Ecore_Thread *) work);
ecore_pipe_write(end_pipe, &work, sizeof (Ecore_Pthread_Worker *));
}
pth->thread = pthread_self();
work->self = pth->thread;
- work->u.feedback_run.func_heavy((Ecore_Thread *) work, (void *) work->data);
+ work->u.feedback_run.func_heavy((void *) work->data, (Ecore_Thread *) work);
ecore_pipe_write(pth->p, &work, sizeof (Ecore_Pthread_Worker *));
EINA_LIST_FREE(_ecore_pending_job_threads, work)
{
if (work->func_cancel)
- work->func_cancel((void *)work->data);
+ work->func_cancel((void *)work->data, (Ecore_Thread *) work);
free(work);
}
EINA_LIST_FREE(_ecore_pending_job_threads_feedback, work)
{
if (work->func_cancel)
- work->func_cancel((void *)work->data);
+ work->func_cancel((void *)work->data, (Ecore_Thread *) work);
free(work);
}
* host CPU can handle.
*/
EAPI Ecore_Thread *
-ecore_thread_run(Ecore_Thread_Heavy_Cb func_blocking,
- Ecore_Cb func_end,
- Ecore_Cb func_cancel,
+ecore_thread_run(Ecore_Thread_Cb func_blocking,
+ Ecore_Thread_Cb func_end,
+ Ecore_Thread_Cb func_cancel,
const void *data)
{
Ecore_Pthread_Worker *work;
if (!work)
{
if (func_cancel)
- func_cancel((void *) data);
+ func_cancel((void *) data, NULL);
return NULL;
}
pthread_mutex_unlock(&_ecore_pending_job_threads_mutex);
if (work->func_cancel)
- work->func_cancel((void *) work->data);
+ work->func_cancel((void *) work->data, (Ecore_Thread *) work);
free(work);
work = NULL;
}
If no thread and as we don't want to break app that rely on this
facility, we will lock the interface until we are done.
*/
- func_blocking((Ecore_Thread *) work, (void *)data);
- func_end((void *)data);
+ func_blocking((void *)data, (Ecore_Thread *) work);
+ if (work->cancel == EINA_FALSE) func_end((void *)data, (Ecore_Thread *) work);
+ else func_end((void *)data, (Ecore_Thread *) work);
+
+ free(work);
return NULL;
#endif
pthread_mutex_unlock(&_ecore_pending_job_threads_mutex);
if (work->func_cancel)
- work->func_cancel((void *) work->data);
+ work->func_cancel((void *) work->data, (Ecore_Thread *) work);
free(work);
return EINA_TRUE;
pthread_mutex_unlock(&_ecore_pending_job_threads_mutex);
if (work->func_cancel)
- work->func_cancel((void *) work->data);
+ work->func_cancel((void *) work->data, (Ecore_Thread *) work);
free(work);
return EINA_TRUE;
* the CPU down, so be careful with that. Of course if it can't start a new thread, it will
* try to use one from the pool.
*/
-EAPI Ecore_Thread *ecore_thread_feedback_run(Ecore_Thread_Heavy_Cb func_heavy,
+EAPI Ecore_Thread *ecore_thread_feedback_run(Ecore_Thread_Cb func_heavy,
Ecore_Thread_Notify_Cb func_notify,
- Ecore_Cb func_end,
- Ecore_Cb func_cancel,
+ Ecore_Thread_Cb func_end,
+ Ecore_Thread_Cb func_cancel,
const void *data,
Eina_Bool try_no_queue)
{
worker);
pthread_mutex_unlock(&_ecore_pending_job_threads_mutex);
- if (func_cancel) func_cancel((void *) data);
+ if (func_cancel) func_cancel((void *) data, NULL);
if (worker)
{
worker.feedback_run = EINA_TRUE;
worker.kill = EINA_FALSE;
- func_heavy((Ecore_Thread *) &worker, (void *)data);
+ func_heavy((void *)data, (Ecore_Thread *) &worker);
- if (worker.func_cancel) func_cancel((void *)data);
- else func_end((void *)data);
+ if (worker.cancel) func_cancel((void *)data, (Ecore_Thread *) &worker);
+ else func_end((void *)data, (Ecore_Thread *) &worker);
return NULL;
#endif
return EINA_TRUE;
#else
- worker->u.feedback_run.func_notify(thread, (void*) data, (void*) worker->data);
+ worker->u.feedback_run.func_notify((void*) worker->data, thread, (void*) data);
return EINA_TRUE;
#endif