diff options
author | Cedric Bail <cedric.bail@samsung.com> | 2013-11-05 11:12:20 +0900 |
---|---|---|
committer | Cedric Bail <cedric.bail@samsung.com> | 2013-11-05 11:12:20 +0900 |
commit | e570ea7805ffb56ee9b95c703fd0a13a7d185b07 (patch) | |
tree | c6ed4d8e8fe05264d8e9898047a7a41bb05c3708 /src | |
parent | b5e68552661dde72aa9a8643830fdb42aa84e525 (diff) |
ecore: remove coroutine for now. Can easily be reverted for 1.9.
Diffstat (limited to '')
-rw-r--r-- | src/Makefile_Ecore.am | 2 | ||||
-rw-r--r-- | src/lib/ecore/Ecore_Common.h | 21 | ||||
-rw-r--r-- | src/lib/ecore/ecore.c | 2 | ||||
-rw-r--r-- | src/lib/ecore/ecore_coroutine.c | 347 | ||||
-rw-r--r-- | src/tests/ecore/ecore_suite.c | 1 | ||||
-rw-r--r-- | src/tests/ecore/ecore_suite.h | 1 | ||||
-rw-r--r-- | src/tests/ecore/ecore_test_coroutine.c | 86 |
7 files changed, 0 insertions, 460 deletions
diff --git a/src/Makefile_Ecore.am b/src/Makefile_Ecore.am index 89cb328de9..dc2a3cae9a 100644 --- a/src/Makefile_Ecore.am +++ b/src/Makefile_Ecore.am | |||
@@ -30,7 +30,6 @@ lib/ecore/ecore_time.c \ | |||
30 | lib/ecore/ecore_timer.c \ | 30 | lib/ecore/ecore_timer.c \ |
31 | lib/ecore/ecore_thread.c \ | 31 | lib/ecore/ecore_thread.c \ |
32 | lib/ecore/ecore_throttle.c \ | 32 | lib/ecore/ecore_throttle.c \ |
33 | lib/ecore/ecore_coroutine.c \ | ||
34 | lib/ecore/ecore_private.h | 33 | lib/ecore/ecore_private.h |
35 | 34 | ||
36 | if HAVE_WIN32 | 35 | if HAVE_WIN32 |
@@ -138,7 +137,6 @@ tests/ecore/ecore_test_ecore.c \ | |||
138 | tests/ecore/ecore_test_ecore_con.c \ | 137 | tests/ecore/ecore_test_ecore_con.c \ |
139 | tests/ecore/ecore_test_ecore_x.c \ | 138 | tests/ecore/ecore_test_ecore_x.c \ |
140 | tests/ecore/ecore_test_ecore_imf.c \ | 139 | tests/ecore/ecore_test_ecore_imf.c \ |
141 | tests/ecore/ecore_test_coroutine.c \ | ||
142 | tests/ecore/ecore_test_timer.c \ | 140 | tests/ecore/ecore_test_timer.c \ |
143 | tests/ecore/ecore_test_ecore_evas.c \ | 141 | tests/ecore/ecore_test_ecore_evas.c \ |
144 | tests/ecore/ecore_test_animator.c \ | 142 | tests/ecore/ecore_test_animator.c \ |
diff --git a/src/lib/ecore/Ecore_Common.h b/src/lib/ecore/Ecore_Common.h index eceb4ed34e..5536d22cd4 100644 --- a/src/lib/ecore/Ecore_Common.h +++ b/src/lib/ecore/Ecore_Common.h | |||
@@ -2216,27 +2216,6 @@ typedef Eo Ecore_Job; /**< A job handle */ | |||
2216 | * @} | 2216 | * @} |
2217 | */ | 2217 | */ |
2218 | 2218 | ||
2219 | typedef struct _Ecore_Coroutine Ecore_Coroutine; | ||
2220 | typedef int (*Ecore_Coroutine_Cb)(void *data, Ecore_Coroutine *coro); | ||
2221 | |||
2222 | typedef enum { | ||
2223 | ECORE_COROUTINE_NEW, | ||
2224 | ECORE_COROUTINE_RUNNING, | ||
2225 | ECORE_COROUTINE_FINISHED | ||
2226 | } Ecore_Coroutine_State; | ||
2227 | |||
2228 | EAPI Ecore_Coroutine *ecore_coroutine_add(int stack_size, Ecore_Coroutine_Cb func, void *data); | ||
2229 | EAPI void *ecore_coroutine_del(Ecore_Coroutine *coro); | ||
2230 | |||
2231 | EAPI int ecore_coroutine_resume(Ecore_Coroutine *coro); | ||
2232 | EAPI void ecore_coroutine_yield(Ecore_Coroutine *coro, int value); | ||
2233 | |||
2234 | EAPI void *ecore_coroutine_data_get(Ecore_Coroutine *coro); | ||
2235 | EAPI Ecore_Coroutine_State ecore_coroutine_state_get(Ecore_Coroutine *coro); | ||
2236 | |||
2237 | EAPI void ecore_coroutine_defer(Ecore_Coroutine *coro, Eina_Free_Cb func, void *data); | ||
2238 | EAPI void *ecore_coroutine_alloc(Ecore_Coroutine *coro, size_t size); | ||
2239 | |||
2240 | #ifdef __cplusplus | 2219 | #ifdef __cplusplus |
2241 | } | 2220 | } |
2242 | #endif | 2221 | #endif |
diff --git a/src/lib/ecore/ecore.c b/src/lib/ecore/ecore.c index d0e98ad895..bbe51babf5 100644 --- a/src/lib/ecore/ecore.c +++ b/src/lib/ecore/ecore.c | |||
@@ -272,7 +272,6 @@ ecore_init(void) | |||
272 | _ecore_glib_init(); | 272 | _ecore_glib_init(); |
273 | _ecore_job_init(); | 273 | _ecore_job_init(); |
274 | _ecore_time_init(); | 274 | _ecore_time_init(); |
275 | _ecore_coroutine_init(); | ||
276 | 275 | ||
277 | eina_lock_new(&_thread_mutex); | 276 | eina_lock_new(&_thread_mutex); |
278 | eina_condition_new(&_thread_cond, &_thread_mutex); | 277 | eina_condition_new(&_thread_cond, &_thread_mutex); |
@@ -385,7 +384,6 @@ ecore_shutdown(void) | |||
385 | #endif | 384 | #endif |
386 | 385 | ||
387 | if (_ecore_fps_debug) _ecore_fps_debug_shutdown(); | 386 | if (_ecore_fps_debug) _ecore_fps_debug_shutdown(); |
388 | _ecore_coroutine_shutdown(); | ||
389 | _ecore_poller_shutdown(); | 387 | _ecore_poller_shutdown(); |
390 | _ecore_animator_shutdown(); | 388 | _ecore_animator_shutdown(); |
391 | _ecore_glib_shutdown(); | 389 | _ecore_glib_shutdown(); |
diff --git a/src/lib/ecore/ecore_coroutine.c b/src/lib/ecore/ecore_coroutine.c deleted file mode 100644 index 07a277a3af..0000000000 --- a/src/lib/ecore/ecore_coroutine.c +++ /dev/null | |||
@@ -1,347 +0,0 @@ | |||
1 | #ifdef HAVE_CONFIG_H | ||
2 | # include <config.h> | ||
3 | #endif | ||
4 | |||
5 | #include <stdlib.h> | ||
6 | #include <sys/time.h> | ||
7 | #include <assert.h> | ||
8 | #include <sys/types.h> | ||
9 | #include <unistd.h> | ||
10 | |||
11 | #if defined(USE_UCONTEXT) | ||
12 | # include <sys/time.h> | ||
13 | # include <sys/resource.h> | ||
14 | # include <ucontext.h> | ||
15 | #elif defined(USE_SETJMP) | ||
16 | # include <sys/time.h> | ||
17 | # if HAVE_SYS_RESOURCE_H | ||
18 | # include <sys/resource.h> | ||
19 | # endif | ||
20 | # include <setjmp.h> | ||
21 | #endif | ||
22 | |||
23 | #ifdef HAVE_EVIL | ||
24 | # include <Evil.h> | ||
25 | #endif | ||
26 | |||
27 | #ifdef _WIN32 | ||
28 | # define USE_FIBERS | ||
29 | # undef USE_UCONTEXT | ||
30 | # undef USE_SETJMP | ||
31 | #endif | ||
32 | |||
33 | #include "Ecore.h" | ||
34 | #include "ecore_private.h" | ||
35 | |||
36 | typedef struct _Ecore_Coroutine_Defer Ecore_Coroutine_Defer; | ||
37 | struct _Ecore_Coroutine_Defer | ||
38 | { | ||
39 | Eina_Free_Cb func; | ||
40 | void *data; | ||
41 | }; | ||
42 | |||
43 | struct _Ecore_Coroutine | ||
44 | { | ||
45 | #if defined(USE_FIBERS) | ||
46 | void *context; | ||
47 | #elif defined(USE_UCONTEXT) | ||
48 | ucontext_t context; | ||
49 | #elif defined(USE_SETJMP) | ||
50 | jmp_buf context; | ||
51 | #else | ||
52 | # error "No coroutine implementation !" | ||
53 | #endif | ||
54 | |||
55 | Eina_Inarray defer; | ||
56 | |||
57 | Ecore_Coroutine_Cb func; | ||
58 | void *data; | ||
59 | |||
60 | Ecore_Coroutine_State state; | ||
61 | |||
62 | #ifdef USE_VALGRIND | ||
63 | int vg_stack_id; | ||
64 | #endif | ||
65 | int yield_value; | ||
66 | |||
67 | unsigned char stack[1]; | ||
68 | }; | ||
69 | |||
70 | #ifdef __x86_64__ | ||
71 | static const int _ecore_coroutine_default_stack_size = 16 * 1024; | ||
72 | #else | ||
73 | static const int _ecore_coroutine_default_stack_size = 12 * 1024; | ||
74 | #endif | ||
75 | |||
76 | static void | ||
77 | _ecore_coroutine_finish(Ecore_Coroutine *coro) | ||
78 | { | ||
79 | int return_value = coro->func(coro->data, coro); | ||
80 | |||
81 | coro->state = ECORE_COROUTINE_FINISHED; | ||
82 | ecore_coroutine_yield(coro, return_value); | ||
83 | } | ||
84 | |||
85 | #if defined(USE_UCONTEXT) | ||
86 | # ifdef __x86_64__ | ||
87 | union ptr_splitter { | ||
88 | void *ptr; | ||
89 | uint32_t part[sizeof(void *) / sizeof(uint32_t)]; | ||
90 | }; | ||
91 | |||
92 | static void | ||
93 | _ecore_coroutine_entry_point(uint32_t part0, uint32_t part1) | ||
94 | { | ||
95 | union ptr_splitter p = { | ||
96 | .part = { part0, part1 } | ||
97 | }; | ||
98 | Ecore_Coroutine *coro = p.ptr; | ||
99 | |||
100 | _ecore_coroutine_finish(coro); | ||
101 | } | ||
102 | # else | ||
103 | static void | ||
104 | _ecore_coroutine_entry_point(Ecore_Coroutine *coro) | ||
105 | { | ||
106 | _ecore_coroutine_finish(coro); | ||
107 | } | ||
108 | # endif | ||
109 | #else | ||
110 | static void | ||
111 | _ecore_coroutine_entry_point(Ecore_Coroutine *coro) | ||
112 | { | ||
113 | _ecore_coroutine_finish(coro); | ||
114 | } | ||
115 | # if defined(USE_SETJMP) | ||
116 | static void | ||
117 | _ecore_coroutine_setjmp(Ecore_Coroutine *coro) | ||
118 | { | ||
119 | setjmp(coro->context); | ||
120 | |||
121 | /* The idea of this trick come from libcoroutine */ | ||
122 | /* __jmpbuf[6] == stack pointer */ | ||
123 | /* __jmpbuf[7] == program counter */ | ||
124 | coro->context->env[0].__jmpbuf[6] = ((uintptr_t)(&coro->stack)); | ||
125 | coro->context->env[0].__jmpbuf[7] = ((uintptr_t)_ecore_coroutine_entry_point); | ||
126 | } | ||
127 | # endif | ||
128 | #endif | ||
129 | |||
130 | #if defined(USE_FIBERS) | ||
131 | static void *caller; | ||
132 | #elif defined(USE_UCONTEXT) | ||
133 | static ucontext_t caller; | ||
134 | static ucontext_t callee; | ||
135 | #elif defined(USE_SETJMP) | ||
136 | static jmp_buf caller; | ||
137 | static jmp_buf callee; | ||
138 | #endif | ||
139 | |||
140 | void | ||
141 | _ecore_coroutine_init(void) | ||
142 | { | ||
143 | #if defined(USE_FIBERS) | ||
144 | caller = GetCurrentFiber(); | ||
145 | if (caller == (LPVOID) 0x1e00) | ||
146 | { | ||
147 | caller = ConvertThreadToFiber(NULL); | ||
148 | } | ||
149 | #else | ||
150 | memset(&caller, 0, sizeof (caller)); | ||
151 | memset(&callee, 0, sizeof (callee)); | ||
152 | #endif | ||
153 | } | ||
154 | |||
155 | void | ||
156 | _ecore_coroutine_shutdown(void) | ||
157 | { | ||
158 | #ifdef USE_FIBERS | ||
159 | ConvertFiberToThread(); | ||
160 | #endif | ||
161 | |||
162 | // FIXME: should we track lost coroutine ? | ||
163 | } | ||
164 | |||
165 | EAPI Ecore_Coroutine * | ||
166 | ecore_coroutine_add(int stack_size, Ecore_Coroutine_Cb func, void *data) | ||
167 | { | ||
168 | Ecore_Coroutine *coro; | ||
169 | #ifndef USE_FIBERS | ||
170 | unsigned char *stack; | ||
171 | #endif | ||
172 | |||
173 | if (stack_size <= 0) | ||
174 | { | ||
175 | #if defined(USE_UCONTEXT) || defined(USE_SETJMP) | ||
176 | struct rlimit check; | ||
177 | |||
178 | if (getrlimit(RLIMIT_STACK, &check)) | ||
179 | check.rlim_cur = _ecore_coroutine_default_stack_size; | ||
180 | stack_size = check.rlim_cur; | ||
181 | #elif defined(USE_FIBERS) | ||
182 | stack_size = _ecore_coroutine_default_stack_size; | ||
183 | #endif | ||
184 | if (stack_size < _ecore_coroutine_default_stack_size) | ||
185 | stack_size = _ecore_coroutine_default_stack_size; | ||
186 | } | ||
187 | |||
188 | coro = malloc(sizeof (Ecore_Coroutine) + stack_size - 1); | ||
189 | if (!coro) return NULL; | ||
190 | |||
191 | #ifndef USE_FIBERS | ||
192 | stack = coro->stack; | ||
193 | #endif | ||
194 | |||
195 | #ifdef USE_VALGRIND | ||
196 | coro->vg_stack_id = VALGRIND_STACK_REGISTER(stack, stack + stack_size); | ||
197 | #endif | ||
198 | |||
199 | coro->state = ECORE_COROUTINE_NEW; | ||
200 | coro->func = func; | ||
201 | coro->data = data; | ||
202 | eina_inarray_step_set(&coro->defer, | ||
203 | sizeof (Eina_Inarray), sizeof (Ecore_Coroutine_Defer), | ||
204 | 8); | ||
205 | |||
206 | #if defined(USE_UCONTEXT) | ||
207 | getcontext(&coro->context); | ||
208 | |||
209 | coro->context.uc_stack.ss_sp = stack; | ||
210 | coro->context.uc_stack.ss_size = stack_size; | ||
211 | coro->context.uc_stack.ss_flags = 0; | ||
212 | coro->context.uc_link = NULL; | ||
213 | |||
214 | # ifdef __x86_64__ | ||
215 | union ptr_splitter p = { .ptr = coro }; | ||
216 | makecontext(&coro->context, (void (*)())_ecore_coroutine_entry_point, | ||
217 | 2, p.part[0], p.part[1]); | ||
218 | # else | ||
219 | makecontext(&coro->context, (void (*)())_ecore_coroutine_entry_point, | ||
220 | 1, coro); | ||
221 | # endif | ||
222 | #elif defined(USE_FIBERS) | ||
223 | coro->context = CreateFiber(stack_size, | ||
224 | (LPFIBER_START_ROUTINE)_ecore_coroutine_entry_point, | ||
225 | coro); | ||
226 | if (!coro->context) | ||
227 | { | ||
228 | free(coro); | ||
229 | return NULL; | ||
230 | } | ||
231 | #elif defined(USE_SETJMP) | ||
232 | /* We use an intermediate function call to setup the stack with the right arguments */ | ||
233 | _ecore_coroutine_setjmp(coro); | ||
234 | #endif | ||
235 | |||
236 | return coro; | ||
237 | } | ||
238 | |||
239 | EAPI void * | ||
240 | ecore_coroutine_del(Ecore_Coroutine *coro) | ||
241 | { | ||
242 | void *data; | ||
243 | |||
244 | data = coro->data; | ||
245 | |||
246 | while (eina_inarray_count(&coro->defer)) | ||
247 | { | ||
248 | Ecore_Coroutine_Defer *defer; | ||
249 | |||
250 | defer = eina_inarray_pop(&coro->defer); | ||
251 | defer->func(defer->data); | ||
252 | } | ||
253 | eina_inarray_flush(&coro->defer); | ||
254 | |||
255 | #ifdef USE_VALGRIND | ||
256 | VALGRIND_STACK_DEREGISTER(coro->vg_stack_id); | ||
257 | #endif | ||
258 | |||
259 | #ifdef USE_FIBERS | ||
260 | DeleteFiber(coro->context); | ||
261 | #endif | ||
262 | |||
263 | free(coro); | ||
264 | return data; | ||
265 | } | ||
266 | |||
267 | EAPI int | ||
268 | ecore_coroutine_resume(Ecore_Coroutine *coro) | ||
269 | { | ||
270 | #if defined(USE_FIBERS) | ||
271 | void *prev_caller; | ||
272 | #elif defined(USE_UCONTEXT) | ||
273 | ucontext_t prev_caller; | ||
274 | #elif defined(USE_SETJMP) | ||
275 | jmp_buf prev_caller; | ||
276 | #endif | ||
277 | |||
278 | if (coro->state == ECORE_COROUTINE_FINISHED) | ||
279 | return 0; | ||
280 | coro->state = ECORE_COROUTINE_RUNNING; | ||
281 | |||
282 | prev_caller = caller; | ||
283 | #if defined(USE_FIBERS) | ||
284 | SwitchToFiber(coro->context); | ||
285 | #elif defined(USE_UCONTEXT) | ||
286 | swapcontext(&caller, &coro->context); | ||
287 | #elif defined(USE_SETJMP) | ||
288 | setjmp(caller); | ||
289 | longjmp(coro->context); | ||
290 | #endif | ||
291 | #ifndef USE_FIBERS | ||
292 | // As fiber do handle the callee stack for us, no need here | ||
293 | coro->context = callee; | ||
294 | #endif | ||
295 | caller = prev_caller; | ||
296 | |||
297 | return coro->yield_value; | ||
298 | } | ||
299 | |||
300 | EAPI void | ||
301 | ecore_coroutine_yield(Ecore_Coroutine *coro, int value) | ||
302 | { | ||
303 | coro->yield_value = value; | ||
304 | #if defined(USE_FIBERS) | ||
305 | SwitchToFiber(caller); | ||
306 | #elif defined(USE_UCONTEXT) | ||
307 | swapcontext(&callee, &caller); | ||
308 | #elif defined(USE_SETJMP) | ||
309 | setjmp(callee); | ||
310 | longjmp(caller); | ||
311 | #endif | ||
312 | } | ||
313 | |||
314 | EAPI void * | ||
315 | ecore_coroutine_data_get(Ecore_Coroutine *coro) | ||
316 | { | ||
317 | return coro->data; | ||
318 | } | ||
319 | |||
320 | EAPI Ecore_Coroutine_State | ||
321 | ecore_coroutine_state_get(Ecore_Coroutine *coro) | ||
322 | { | ||
323 | return coro->state; | ||
324 | } | ||
325 | |||
326 | EAPI void | ||
327 | ecore_coroutine_defer(Ecore_Coroutine *coro, Eina_Free_Cb func, void *data) | ||
328 | { | ||
329 | Ecore_Coroutine_Defer *defer; | ||
330 | |||
331 | defer = eina_inarray_grow(&coro->defer, 1); | ||
332 | if (!defer) return; | ||
333 | defer->func = func; | ||
334 | defer->data = data; | ||
335 | } | ||
336 | |||
337 | EAPI void * | ||
338 | ecore_coroutine_alloc(Ecore_Coroutine *coro, size_t size) | ||
339 | { | ||
340 | void *data; | ||
341 | |||
342 | data = malloc(size); | ||
343 | ecore_coroutine_defer(coro, free, data); | ||
344 | return data; | ||
345 | } | ||
346 | |||
347 | |||
diff --git a/src/tests/ecore/ecore_suite.c b/src/tests/ecore/ecore_suite.c index e9e737069a..7119d7df81 100644 --- a/src/tests/ecore/ecore_suite.c +++ b/src/tests/ecore/ecore_suite.c | |||
@@ -25,7 +25,6 @@ static const Ecore_Test_Case etc[] = { | |||
25 | #if HAVE_ECORE_AUDIO | 25 | #if HAVE_ECORE_AUDIO |
26 | { "Ecore Audio", ecore_test_ecore_audio}, | 26 | { "Ecore Audio", ecore_test_ecore_audio}, |
27 | #endif | 27 | #endif |
28 | { "Ecore_Coroutine", ecore_test_coroutine }, | ||
29 | { "Ecore_Timers", ecore_test_timer }, | 28 | { "Ecore_Timers", ecore_test_timer }, |
30 | { "Ecore_Evas", ecore_test_ecore_evas }, | 29 | { "Ecore_Evas", ecore_test_ecore_evas }, |
31 | { "Ecore_Animators", ecore_test_animator }, | 30 | { "Ecore_Animators", ecore_test_animator }, |
diff --git a/src/tests/ecore/ecore_suite.h b/src/tests/ecore/ecore_suite.h index 03f13ef440..4514733c4d 100644 --- a/src/tests/ecore/ecore_suite.h +++ b/src/tests/ecore/ecore_suite.h | |||
@@ -8,7 +8,6 @@ void ecore_test_ecore_con(TCase *tc); | |||
8 | void ecore_test_ecore_x(TCase *tc); | 8 | void ecore_test_ecore_x(TCase *tc); |
9 | void ecore_test_ecore_imf(TCase *tc); | 9 | void ecore_test_ecore_imf(TCase *tc); |
10 | void ecore_test_ecore_audio(TCase *tc); | 10 | void ecore_test_ecore_audio(TCase *tc); |
11 | void ecore_test_coroutine(TCase *tc); | ||
12 | void ecore_test_timer(TCase *tc); | 11 | void ecore_test_timer(TCase *tc); |
13 | void ecore_test_ecore_evas(TCase *tc); | 12 | void ecore_test_ecore_evas(TCase *tc); |
14 | void ecore_test_animator(TCase *tc); | 13 | void ecore_test_animator(TCase *tc); |
diff --git a/src/tests/ecore/ecore_test_coroutine.c b/src/tests/ecore/ecore_test_coroutine.c deleted file mode 100644 index 8d807375be..0000000000 --- a/src/tests/ecore/ecore_test_coroutine.c +++ /dev/null | |||
@@ -1,86 +0,0 @@ | |||
1 | #ifdef HAVE_CONFIG_H | ||
2 | # include <config.h> | ||
3 | #endif | ||
4 | |||
5 | #include <stdio.h> | ||
6 | #include <unistd.h> | ||
7 | |||
8 | #include <Eina.h> | ||
9 | #include <Ecore.h> | ||
10 | |||
11 | #include "ecore_suite.h" | ||
12 | |||
13 | typedef struct _Ecore_Coroutine_Test Ecore_Coroutine_Test; | ||
14 | struct _Ecore_Coroutine_Test | ||
15 | { | ||
16 | unsigned int v; | ||
17 | unsigned int s; | ||
18 | }; | ||
19 | |||
20 | static Ecore_Coroutine_Test t1; | ||
21 | |||
22 | static int | ||
23 | _ecore_test_v1(void *data, Ecore_Coroutine *coro) | ||
24 | { | ||
25 | int *t = data; | ||
26 | |||
27 | ecore_coroutine_yield(coro, 7); | ||
28 | t1.v = *t; | ||
29 | ecore_coroutine_yield(coro, 42); | ||
30 | t1.s = *t; | ||
31 | |||
32 | return 0xDEADBEEF; | ||
33 | } | ||
34 | |||
35 | static int | ||
36 | _ecore_test_v2(void *data, Ecore_Coroutine *coro EINA_UNUSED) | ||
37 | { | ||
38 | int *t = data; | ||
39 | |||
40 | ecore_coroutine_yield(coro, 42); | ||
41 | t1.v = *t; | ||
42 | ecore_coroutine_yield(coro, 7); | ||
43 | t1.s = *t; | ||
44 | |||
45 | return 0xDEADBEEF; | ||
46 | } | ||
47 | |||
48 | START_TEST(ecore_test_coroutine_simple) | ||
49 | { | ||
50 | Ecore_Coroutine *coro1; | ||
51 | Ecore_Coroutine *coro2; | ||
52 | unsigned int value[] = { 7, 42, 0xDEADBEEF }; | ||
53 | |||
54 | ecore_init(); | ||
55 | |||
56 | t1.v = 0xDEADBEEF; t1.s = 0xDEADBEEF; | ||
57 | |||
58 | coro1 = ecore_coroutine_add(0, _ecore_test_v1, &value[0]); | ||
59 | coro2 = ecore_coroutine_add(4*1024*1024, _ecore_test_v2, &value[1]); | ||
60 | |||
61 | fail_if(ecore_coroutine_state_get(coro1) != ECORE_COROUTINE_NEW); | ||
62 | fail_if(ecore_coroutine_resume(coro1) != 7); | ||
63 | fail_if(t1.v != 0xDEADBEEF || t1.s != 0xDEADBEEF); | ||
64 | fail_if(ecore_coroutine_resume(coro2) != 42); | ||
65 | fail_if(t1.v != 0xDEADBEEF || t1.s != 0xDEADBEEF); | ||
66 | fail_if(ecore_coroutine_resume(coro1) != 42); | ||
67 | fail_if(t1.v != value[0] || t1.s != 0xDEADBEEF); | ||
68 | fail_if((unsigned int) ecore_coroutine_resume(coro1) != 0xDEADBEEF); | ||
69 | fail_if(t1.v != value[0] || t1.s != value[0]); | ||
70 | fail_if(ecore_coroutine_resume(coro2) != 7); | ||
71 | fail_if(t1.v != value[1] || t1.s != value[0]); | ||
72 | fail_if((unsigned int) ecore_coroutine_resume(coro2) != 0xDEADBEEF); | ||
73 | fail_if(t1.v != value[1] || t1.s != value[1]); | ||
74 | fail_if(ecore_coroutine_state_get(coro2) != ECORE_COROUTINE_FINISHED); | ||
75 | |||
76 | fail_if(ecore_coroutine_del(coro1) != &value[0]); | ||
77 | fail_if(ecore_coroutine_del(coro2) != &value[1]); | ||
78 | |||
79 | ecore_shutdown(); | ||
80 | } | ||
81 | END_TEST | ||
82 | |||
83 | void ecore_test_coroutine(TCase *tc) | ||
84 | { | ||
85 | tcase_add_test(tc, ecore_test_coroutine_simple); | ||
86 | } | ||