summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Makefile_Ecore.am1
-rw-r--r--src/lib/ecore/Ecore_Common.h2
-rw-r--r--src/lib/ecore/Ecore_Eo.h12
-rw-r--r--src/lib/ecore/Ecore_Legacy.h2
-rw-r--r--src/lib/ecore/ecore_job.c74
-rw-r--r--src/lib/ecore/ecore_job.eo29
6 files changed, 22 insertions, 98 deletions
diff --git a/src/Makefile_Ecore.am b/src/Makefile_Ecore.am
index e890c75..2eefeaa 100644
--- a/src/Makefile_Ecore.am
+++ b/src/Makefile_Ecore.am
@@ -4,7 +4,6 @@
4ecore_eolian_files_legacy = \ 4ecore_eolian_files_legacy = \
5 lib/ecore/ecore_timer.eo \ 5 lib/ecore/ecore_timer.eo \
6 lib/ecore/ecore_poller.eo \ 6 lib/ecore/ecore_poller.eo \
7 lib/ecore/ecore_job.eo \
8 lib/ecore/ecore_exe.eo \ 7 lib/ecore/ecore_exe.eo \
9 lib/ecore/ecore_animator.eo 8 lib/ecore/ecore_animator.eo
10 9
diff --git a/src/lib/ecore/Ecore_Common.h b/src/lib/ecore/Ecore_Common.h
index 04ee28d..7d7164a 100644
--- a/src/lib/ecore/Ecore_Common.h
+++ b/src/lib/ecore/Ecore_Common.h
@@ -3076,7 +3076,7 @@ typedef struct _Ecore_Factorized_Idle Ecore_Idle_Exiter; /**< A handle for idle
3076/** 3076/**
3077 * @since 1.8 3077 * @since 1.8
3078 */ 3078 */
3079typedef Eo Ecore_Job; /**< A job handle */ 3079typedef struct _Ecore_Job Ecore_Job; /**< A job handle */
3080 3080
3081#define _ECORE_JOB_EO_CLASS_TYPE 3081#define _ECORE_JOB_EO_CLASS_TYPE
3082/** 3082/**
diff --git a/src/lib/ecore/Ecore_Eo.h b/src/lib/ecore/Ecore_Eo.h
index 04bc2f6..edd352a 100644
--- a/src/lib/ecore/Ecore_Eo.h
+++ b/src/lib/ecore/Ecore_Eo.h
@@ -55,18 +55,6 @@ extern "C" {
55 55
56 56
57/** 57/**
58 * @ingroup Ecore_Job_Group
59 *
60 * @{
61 */
62
63#include "ecore_job.eo.h"
64
65/**
66 * @}
67 */
68
69/**
70 * @ingroup Ecore_MainLoop_Group 58 * @ingroup Ecore_MainLoop_Group
71 * 59 *
72 * @{ 60 * @{
diff --git a/src/lib/ecore/Ecore_Legacy.h b/src/lib/ecore/Ecore_Legacy.h
index f0acb5d..4c5145c 100644
--- a/src/lib/ecore/Ecore_Legacy.h
+++ b/src/lib/ecore/Ecore_Legacy.h
@@ -361,8 +361,6 @@ EAPI Ecore_Job *ecore_job_add(Ecore_Cb func, const void *data);
361 */ 361 */
362EAPI void *ecore_job_del(Ecore_Job *obj); 362EAPI void *ecore_job_del(Ecore_Job *obj);
363 363
364#include "ecore_job.eo.legacy.h"
365
366/** 364/**
367 * @} 365 * @}
368 */ 366 */
diff --git a/src/lib/ecore/ecore_job.c b/src/lib/ecore/ecore_job.c
index 91e634f..302b767 100644
--- a/src/lib/ecore/ecore_job.c
+++ b/src/lib/ecore/ecore_job.c
@@ -9,10 +9,6 @@
9#include "Ecore.h" 9#include "Ecore.h"
10#include "ecore_private.h" 10#include "ecore_private.h"
11 11
12#define MY_CLASS ECORE_JOB_CLASS
13
14#define MY_CLASS_NAME "Ecore_Job"
15
16static Eina_Bool _ecore_job_event_handler(void *data, 12static Eina_Bool _ecore_job_event_handler(void *data,
17 int type, 13 int type,
18 void *ev); 14 void *ev);
@@ -22,9 +18,7 @@ static void _ecore_job_event_free(void *data,
22static int ecore_event_job_type = 0; 18static int ecore_event_job_type = 0;
23static Ecore_Event_Handler *_ecore_job_handler = NULL; 19static Ecore_Event_Handler *_ecore_job_handler = NULL;
24 20
25typedef struct _Ecore_Job_Data Ecore_Job_Data; 21struct _Ecore_Job
26
27struct _Ecore_Job_Data
28{ 22{
29 Ecore_Event *event; 23 Ecore_Event *event;
30 Ecore_Cb func; 24 Ecore_Cb func;
@@ -49,65 +43,48 @@ EAPI Ecore_Job *
49ecore_job_add(Ecore_Cb func, 43ecore_job_add(Ecore_Cb func,
50 const void *data) 44 const void *data)
51{ 45{
52 Ecore_Job *job = eo_add(MY_CLASS, _ecore_parent, ecore_job_constructor(eo_self, func, data)); 46 Ecore_Job *job;
53 return job;
54}
55 47
56EOLIAN static void
57_ecore_job_constructor(Eo *obj, Ecore_Job_Data *job, Ecore_Cb func, const void *data)
58{
59 if (EINA_UNLIKELY(!eina_main_loop_is())) 48 if (EINA_UNLIKELY(!eina_main_loop_is()))
60 { 49 {
61 EINA_MAIN_LOOP_CHECK_RETURN; 50 EINA_MAIN_LOOP_CHECK_RETURN_VAL(NULL);
62 } 51 }
63 eo_manual_free_set(obj, EINA_TRUE);
64 52
65 if (!func) 53 if (!func)
66 { 54 {
67 ERR("callback function must be set up for an object of class: '%s'", MY_CLASS_NAME); 55 ERR("Callback function must be set up for an Ecore_Job object");
68 return; 56 return NULL;
69 } 57 }
70 58
71 job->event = ecore_event_add(ecore_event_job_type, job, _ecore_job_event_free, obj); 59 job = calloc(1, sizeof (Ecore_Job));
60 if (!job) return NULL;
61
62 job->event = ecore_event_add(ecore_event_job_type, job, _ecore_job_event_free, job);
72 if (!job->event) 63 if (!job->event)
73 { 64 {
74 ERR("no event was assigned to object '%p' of class '%s'", obj, MY_CLASS_NAME); 65 ERR("No event was assigned to Ecore_Job '%p'", job);
75 return; 66 free(job);
67 return NULL;
76 } 68 }
77 job->func = func; 69 job->func = func;
78 job->data = (void *)data; 70 job->data = (void *)data;
71
72 return job;
79} 73}
80 74
81EAPI void * 75EAPI void *
82ecore_job_del(Ecore_Job *obj) 76ecore_job_del(Ecore_Job *job)
83{ 77{
84 void *data; 78 void *data;
85 79
86 if (!obj) return NULL; 80 if (!job) return NULL;
81
87 EINA_MAIN_LOOP_CHECK_RETURN_VAL(NULL); 82 EINA_MAIN_LOOP_CHECK_RETURN_VAL(NULL);
88 Ecore_Job_Data *job = eo_data_scope_get(obj, MY_CLASS); 83
89 data = job->data; 84 data = job->data;
90 ecore_event_del(job->event); 85 ecore_event_del(job->event);
91 eo_parent_set(obj, NULL);
92 return data;
93}
94
95EOLIAN static void
96_ecore_job_eo_base_destructor(Eo *obj, Ecore_Job_Data *_pd EINA_UNUSED)
97{
98 /*FIXME: check if ecore_event_del should be called from here*/
99 eo_destructor(eo_super(obj, MY_CLASS));
100}
101 86
102EOLIAN static Eo * 87 return data;
103_ecore_job_eo_base_finalize(Eo *obj, Ecore_Job_Data *pd)
104{
105 if (!pd->func)
106 {
107 return NULL;
108 }
109
110 return eo_finalize(eo_super(obj, MY_CLASS));
111} 88}
112 89
113static Eina_Bool 90static Eina_Bool
@@ -115,7 +92,7 @@ _ecore_job_event_handler(void *data EINA_UNUSED,
115 int type EINA_UNUSED, 92 int type EINA_UNUSED,
116 void *ev) 93 void *ev)
117{ 94{
118 Ecore_Job_Data *job; 95 Ecore_Job *job;
119 96
120 job = ev; 97 job = ev;
121 job->func(job->data); 98 job->func(job->data);
@@ -126,14 +103,5 @@ static void
126_ecore_job_event_free(void *data, 103_ecore_job_event_free(void *data,
127 void *job EINA_UNUSED) 104 void *job EINA_UNUSED)
128{ 105{
129 eo_parent_set(data, NULL); 106 ecore_job_del(data);
130
131 Ecore_Job *obj = data;
132
133 if (eo_destructed_is(obj))
134 eo_manual_free(obj);
135 else
136 eo_manual_free_set(obj, EINA_FALSE);
137} 107}
138
139#include "ecore_job.eo.c"
diff --git a/src/lib/ecore/ecore_job.eo b/src/lib/ecore/ecore_job.eo
deleted file mode 100644
index 26dedec..0000000
--- a/src/lib/ecore/ecore_job.eo
+++ /dev/null
@@ -1,29 +0,0 @@
1import ecore_types;
2
3class Ecore.Job (Eo.Base)
4{
5 [[Ecore Jobs are queued until the main loop dealt with the current event.
6
7 Jobs are processed by the main loop similarly to events. They also will
8 be executed in the order in which they were added.
9 ]]
10
11 eo_prefix: ecore_job;
12 methods {
13 constructor {
14 [[Constructor.]]
15 legacy: null;
16 params {
17 @in func: Ecore_Cb; [[Ecore job to be queued callback function.]]
18 @in data: const(void)*; [[Private data passed to callback function.]]
19 }
20 }
21 }
22 implements {
23 Eo.Base.destructor;
24 Eo.Base.finalize;
25 }
26 constructors {
27 .constructor;
28 }
29}