diff options
author | Yakov Goldberg <yakov.g@samsung.com> | 2012-10-10 08:19:58 +0000 |
---|---|---|
committer | Daniel Zaoui <daniel.zaoui@yahoo.com> | 2012-10-10 08:19:58 +0000 |
commit | dbda81582a7669044f61d22549727e4799e8184f (patch) | |
tree | ae265363db08486947116bce46b3faa20749a55c /legacy/ecore/src/lib/ecore/ecore_timer.c | |
parent | fa1dd2b86ff0a8a6679d7b1de64dbe09b17afdce (diff) |
Porting to Eo: Job, Animator, Idler, Idle_Enterer, Idle_Exiter, Timer, Ecore_Poll
Signed-off-by: Yakov Goldberg <yakov.g@samsung.com>
SVN revision: 77722
Diffstat (limited to '')
-rw-r--r-- | legacy/ecore/src/lib/ecore/ecore_timer.c | 497 |
1 files changed, 333 insertions, 164 deletions
diff --git a/legacy/ecore/src/lib/ecore/ecore_timer.c b/legacy/ecore/src/lib/ecore/ecore_timer.c index 343c89f571..0ab4230dbe 100644 --- a/legacy/ecore/src/lib/ecore/ecore_timer.c +++ b/legacy/ecore/src/lib/ecore/ecore_timer.c | |||
@@ -8,6 +8,17 @@ | |||
8 | #include "Ecore.h" | 8 | #include "Ecore.h" |
9 | #include "ecore_private.h" | 9 | #include "ecore_private.h" |
10 | 10 | ||
11 | #include "Eo.h" | ||
12 | |||
13 | #define MY_CLASS ECORE_TIMER_CLASS | ||
14 | #define MY_CLASS_NAME "ecore_timer" | ||
15 | |||
16 | EAPI Eo_Op ECORE_TIMER_BASE_ID = EO_NOOP; | ||
17 | |||
18 | #define ECORE_TIMER_CHECK(obj) \ | ||
19 | if (!eo_isa((obj), ECORE_TIMER_CLASS)) \ | ||
20 | return | ||
21 | |||
11 | #ifdef WANT_ECORE_TIMER_DUMP | 22 | #ifdef WANT_ECORE_TIMER_DUMP |
12 | # include <string.h> | 23 | # include <string.h> |
13 | # include <execinfo.h> | 24 | # include <execinfo.h> |
@@ -15,10 +26,10 @@ | |||
15 | typedef void (*Ecore_Timer_Bt_Func)(); | 26 | typedef void (*Ecore_Timer_Bt_Func)(); |
16 | #endif | 27 | #endif |
17 | 28 | ||
18 | struct _Ecore_Timer | 29 | struct _Ecore_Timer_Private_Data |
19 | { | 30 | { |
20 | EINA_INLIST; | 31 | EINA_INLIST; |
21 | ECORE_MAGIC; | 32 | Ecore_Timer *obj; |
22 | double in; | 33 | double in; |
23 | double at; | 34 | double at; |
24 | double pending; | 35 | double pending; |
@@ -35,9 +46,10 @@ struct _Ecore_Timer | |||
35 | unsigned char just_added : 1; | 46 | unsigned char just_added : 1; |
36 | unsigned char frozen : 1; | 47 | unsigned char frozen : 1; |
37 | }; | 48 | }; |
38 | GENERIC_ALLOC_SIZE_DECLARE(Ecore_Timer); | ||
39 | 49 | ||
40 | static void _ecore_timer_set(Ecore_Timer *timer, | 50 | typedef struct _Ecore_Timer_Private_Data Ecore_Timer_Private_Data; |
51 | |||
52 | static void _ecore_timer_set(Ecore_Timer *timer, | ||
41 | double at, | 53 | double at, |
42 | double in, | 54 | double in, |
43 | Ecore_Task_Cb func, | 55 | Ecore_Task_Cb func, |
@@ -49,9 +61,9 @@ static int _ecore_timer_cmp(const void *d1, | |||
49 | 61 | ||
50 | static int timers_added = 0; | 62 | static int timers_added = 0; |
51 | static int timers_delete_me = 0; | 63 | static int timers_delete_me = 0; |
52 | static Ecore_Timer *timers = NULL; | 64 | static Ecore_Timer_Private_Data *timers = NULL; |
53 | static Ecore_Timer *timer_current = NULL; | 65 | static Ecore_Timer_Private_Data *timer_current = NULL; |
54 | static Ecore_Timer *suspended = NULL; | 66 | static Ecore_Timer_Private_Data *suspended = NULL; |
55 | static double last_check = 0.0; | 67 | static double last_check = 0.0; |
56 | static double precision = 10.0 / 1000000.0; | 68 | static double precision = 10.0 / 1000000.0; |
57 | 69 | ||
@@ -138,29 +150,89 @@ ecore_timer_add(double in, | |||
138 | Ecore_Task_Cb func, | 150 | Ecore_Task_Cb func, |
139 | const void *data) | 151 | const void *data) |
140 | { | 152 | { |
141 | double now; | ||
142 | Ecore_Timer *timer = NULL; | 153 | Ecore_Timer *timer = NULL; |
143 | 154 | ||
144 | EINA_MAIN_LOOP_CHECK_RETURN_VAL(NULL); | 155 | EINA_MAIN_LOOP_CHECK_RETURN_VAL(NULL); |
145 | _ecore_lock(); | 156 | timer = eo_add_custom(MY_CLASS, _ecore_parent, ecore_timer_constructor(in, func, data)); |
146 | if (!func) goto unlock; | 157 | eo_unref(timer); |
158 | return timer; | ||
159 | } | ||
160 | |||
161 | static Eina_Bool | ||
162 | _ecore_timer_add(Ecore_Timer *obj, | ||
163 | Ecore_Timer_Private_Data *timer, | ||
164 | double now, | ||
165 | double in, | ||
166 | Ecore_Task_Cb func, | ||
167 | const void *data) | ||
168 | { | ||
169 | |||
170 | if (EINA_UNLIKELY(!eina_main_loop_is())) | ||
171 | { | ||
172 | eo_error_set(obj); | ||
173 | EINA_MAIN_LOOP_CHECK_RETURN_VAL(EINA_FALSE); | ||
174 | } | ||
175 | |||
176 | timer->obj = obj; | ||
177 | eo_do_super(obj, eo_constructor()); | ||
178 | eo_manual_free_set(obj, EINA_TRUE); | ||
179 | |||
180 | if (!func) | ||
181 | { | ||
182 | eo_error_set(obj); | ||
183 | ERR("callback function must be set up for an object of class: '%s'", MY_CLASS_NAME); | ||
184 | return EINA_FALSE; | ||
185 | } | ||
186 | |||
147 | if (in < 0.0) in = 0.0; | 187 | if (in < 0.0) in = 0.0; |
148 | timer = ecore_timer_calloc(1); | ||
149 | if (!timer) goto unlock; | ||
150 | ECORE_MAGIC_SET(timer, ECORE_MAGIC_TIMER); | ||
151 | now = ecore_time_get(); | ||
152 | 188 | ||
153 | #ifdef WANT_ECORE_TIMER_DUMP | 189 | #ifdef WANT_ECORE_TIMER_DUMP |
154 | timer->timer_bt_num = backtrace((void **)(timer->timer_bt), | 190 | timer->timer_bt_num = backtrace((void **)(timer->timer_bt), |
155 | ECORE_TIMER_DEBUG_BT_NUM); | 191 | ECORE_TIMER_DEBUG_BT_NUM); |
156 | #endif | 192 | #endif |
193 | _ecore_timer_set(obj, now + in, in, func, (void *)data); | ||
194 | return EINA_TRUE; | ||
195 | } | ||
157 | 196 | ||
158 | _ecore_timer_set(timer, now + in, in, func, (void *)data); | 197 | static void |
159 | unlock: | 198 | _timer_constructor(Eo *obj, void *_pd, va_list *list) |
199 | { | ||
200 | double in = va_arg(*list, double); | ||
201 | Ecore_Task_Cb func = va_arg(*list, Ecore_Task_Cb); | ||
202 | const void *data = va_arg(*list, const void *); | ||
203 | double now; | ||
204 | |||
205 | _ecore_lock(); | ||
206 | now = ecore_time_get(); | ||
207 | |||
208 | Ecore_Timer_Private_Data *timer = _pd; | ||
209 | _ecore_timer_add(obj, timer, now, in, func, data); | ||
160 | _ecore_unlock(); | 210 | _ecore_unlock(); |
161 | return timer; | ||
162 | } | 211 | } |
163 | 212 | ||
213 | static void | ||
214 | _timer_loop_constructor(Eo *obj, void *_pd, va_list *list) | ||
215 | { | ||
216 | double in = va_arg(*list, double); | ||
217 | Ecore_Task_Cb func = va_arg(*list, Ecore_Task_Cb); | ||
218 | const void *data = va_arg(*list, const void *); | ||
219 | double now; | ||
220 | |||
221 | _ecore_lock(); | ||
222 | now = ecore_loop_time_get(); | ||
223 | |||
224 | Ecore_Timer_Private_Data *timer = _pd; | ||
225 | _ecore_timer_add(obj, timer, now, in, func, data); | ||
226 | } | ||
227 | |||
228 | static void | ||
229 | _constructor(Eo *obj, void *_pd EINA_UNUSED, va_list *list EINA_UNUSED) | ||
230 | { | ||
231 | eo_error_set(obj); | ||
232 | ERR("only custom constructor can be used with '%s' class", MY_CLASS_NAME); | ||
233 | } | ||
234 | |||
235 | |||
164 | /** | 236 | /** |
165 | * Creates a timer to call the given function in the given period of time. | 237 | * Creates a timer to call the given function in the given period of time. |
166 | * @param in The interval in seconds from current loop time. | 238 | * @param in The interval in seconds from current loop time. |
@@ -180,7 +252,6 @@ ecore_timer_loop_add(double in, | |||
180 | { | 252 | { |
181 | Ecore_Timer *timer; | 253 | Ecore_Timer *timer; |
182 | 254 | ||
183 | EINA_MAIN_LOOP_CHECK_RETURN_VAL(NULL); | ||
184 | _ecore_lock(); | 255 | _ecore_lock(); |
185 | timer = _ecore_timer_loop_add(in, func, data); | 256 | timer = _ecore_timer_loop_add(in, func, data); |
186 | _ecore_unlock(); | 257 | _ecore_unlock(); |
@@ -205,16 +276,8 @@ ecore_timer_del(Ecore_Timer *timer) | |||
205 | EINA_MAIN_LOOP_CHECK_RETURN_VAL(NULL); | 276 | EINA_MAIN_LOOP_CHECK_RETURN_VAL(NULL); |
206 | _ecore_lock(); | 277 | _ecore_lock(); |
207 | 278 | ||
208 | if (!ECORE_MAGIC_CHECK(timer, ECORE_MAGIC_TIMER)) | ||
209 | { | ||
210 | ECORE_MAGIC_FAIL(timer, ECORE_MAGIC_TIMER, | ||
211 | "ecore_timer_del"); | ||
212 | goto unlock; | ||
213 | } | ||
214 | |||
215 | data = _ecore_timer_del(timer); | 279 | data = _ecore_timer_del(timer); |
216 | 280 | ||
217 | unlock: | ||
218 | _ecore_unlock(); | 281 | _ecore_unlock(); |
219 | return data; | 282 | return data; |
220 | } | 283 | } |
@@ -230,17 +293,20 @@ EAPI void | |||
230 | ecore_timer_interval_set(Ecore_Timer *timer, | 293 | ecore_timer_interval_set(Ecore_Timer *timer, |
231 | double in) | 294 | double in) |
232 | { | 295 | { |
296 | ECORE_TIMER_CHECK(timer); | ||
297 | eo_do(timer, ecore_obj_timer_interval_set(in)); | ||
298 | } | ||
299 | |||
300 | static void | ||
301 | _timer_interval_set(Eo *obj EINA_UNUSED, void *_pd, va_list *list) | ||
302 | { | ||
233 | EINA_MAIN_LOOP_CHECK_RETURN; | 303 | EINA_MAIN_LOOP_CHECK_RETURN; |
234 | _ecore_lock(); | 304 | double in = va_arg(*list, double); |
235 | if (in < 0.0) in = 0.0; | 305 | if (in < 0.0) in = 0.0; |
236 | if (!ECORE_MAGIC_CHECK(timer, ECORE_MAGIC_TIMER)) | 306 | Ecore_Timer_Private_Data *timer = _pd; |
237 | { | 307 | |
238 | ECORE_MAGIC_FAIL(timer, ECORE_MAGIC_TIMER, | 308 | _ecore_lock(); |
239 | "ecore_timer_interval_set"); | ||
240 | goto unlock; | ||
241 | } | ||
242 | timer->in = in; | 309 | timer->in = in; |
243 | unlock: | ||
244 | _ecore_unlock(); | 310 | _ecore_unlock(); |
245 | } | 311 | } |
246 | 312 | ||
@@ -253,23 +319,24 @@ unlock: | |||
253 | EAPI double | 319 | EAPI double |
254 | ecore_timer_interval_get(Ecore_Timer *timer) | 320 | ecore_timer_interval_get(Ecore_Timer *timer) |
255 | { | 321 | { |
256 | double interval; | 322 | double interval = -1.0; |
257 | 323 | ||
258 | EINA_MAIN_LOOP_CHECK_RETURN_VAL(0.0); | 324 | ECORE_TIMER_CHECK(timer) interval; |
259 | _ecore_lock(); | 325 | eo_do(timer, ecore_obj_timer_interval_get(&interval)); |
326 | return interval; | ||
327 | } | ||
260 | 328 | ||
261 | if (!ECORE_MAGIC_CHECK(timer, ECORE_MAGIC_TIMER)) | 329 | static void |
262 | { | 330 | _timer_interval_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list) |
263 | ECORE_MAGIC_FAIL(timer, ECORE_MAGIC_TIMER, | 331 | { |
264 | "ecore_timer_interval_get"); | 332 | double *ret = va_arg(*list, double *); |
265 | interval = -1.0; | 333 | *ret = -1.0; |
266 | goto unlock; | ||
267 | } | ||
268 | 334 | ||
269 | interval = timer->in; | 335 | EINA_MAIN_LOOP_CHECK_RETURN; |
270 | unlock: | 336 | Ecore_Timer_Private_Data *timer = _pd; |
337 | _ecore_lock(); | ||
338 | *ret = timer->in; | ||
271 | _ecore_unlock(); | 339 | _ecore_unlock(); |
272 | return interval; | ||
273 | } | 340 | } |
274 | 341 | ||
275 | /** | 342 | /** |
@@ -283,16 +350,18 @@ EAPI void | |||
283 | ecore_timer_delay(Ecore_Timer *timer, | 350 | ecore_timer_delay(Ecore_Timer *timer, |
284 | double add) | 351 | double add) |
285 | { | 352 | { |
353 | ECORE_TIMER_CHECK(timer); | ||
354 | eo_do(timer, ecore_obj_timer_delay(add)); | ||
355 | } | ||
356 | |||
357 | static void | ||
358 | _timer_delay(Eo *obj, void *_pd EINA_UNUSED, va_list *list) | ||
359 | { | ||
360 | double add = va_arg(*list, double); | ||
286 | EINA_MAIN_LOOP_CHECK_RETURN; | 361 | EINA_MAIN_LOOP_CHECK_RETURN; |
287 | if (!ECORE_MAGIC_CHECK(timer, ECORE_MAGIC_TIMER)) | ||
288 | { | ||
289 | ECORE_MAGIC_FAIL(timer, ECORE_MAGIC_TIMER, | ||
290 | "ecore_timer_delay"); | ||
291 | return; | ||
292 | } | ||
293 | 362 | ||
294 | _ecore_lock(); | 363 | _ecore_lock(); |
295 | _ecore_timer_delay(timer, add); | 364 | _ecore_timer_delay(obj, add); |
296 | _ecore_unlock(); | 365 | _ecore_unlock(); |
297 | } | 366 | } |
298 | 367 | ||
@@ -309,14 +378,18 @@ ecore_timer_delay(Ecore_Timer *timer, | |||
309 | EAPI void | 378 | EAPI void |
310 | ecore_timer_reset(Ecore_Timer *timer) | 379 | ecore_timer_reset(Ecore_Timer *timer) |
311 | { | 380 | { |
381 | ECORE_TIMER_CHECK(timer); | ||
382 | eo_do(timer, ecore_obj_timer_reset()); | ||
383 | } | ||
384 | |||
385 | static void | ||
386 | _timer_reset(Eo *obj, void *_pd, va_list *list EINA_UNUSED) | ||
387 | { | ||
312 | double now, add; | 388 | double now, add; |
313 | EINA_MAIN_LOOP_CHECK_RETURN; | 389 | EINA_MAIN_LOOP_CHECK_RETURN; |
314 | if (!ECORE_MAGIC_CHECK(timer, ECORE_MAGIC_TIMER)) | 390 | |
315 | { | 391 | Ecore_Timer_Private_Data *timer = _pd; |
316 | ECORE_MAGIC_FAIL(timer, ECORE_MAGIC_TIMER, | 392 | |
317 | __func__); | ||
318 | return; | ||
319 | } | ||
320 | _ecore_lock(); | 393 | _ecore_lock(); |
321 | now = ecore_time_get(); | 394 | now = ecore_time_get(); |
322 | 395 | ||
@@ -324,7 +397,7 @@ ecore_timer_reset(Ecore_Timer *timer) | |||
324 | add = timer->pending; | 397 | add = timer->pending; |
325 | else | 398 | else |
326 | add = timer->at - now; | 399 | add = timer->at - now; |
327 | _ecore_timer_delay(timer, timer->in - add); | 400 | _ecore_timer_delay(obj, timer->in - add); |
328 | _ecore_unlock(); | 401 | _ecore_unlock(); |
329 | } | 402 | } |
330 | 403 | ||
@@ -338,30 +411,33 @@ ecore_timer_reset(Ecore_Timer *timer) | |||
338 | EAPI double | 411 | EAPI double |
339 | ecore_timer_pending_get(Ecore_Timer *timer) | 412 | ecore_timer_pending_get(Ecore_Timer *timer) |
340 | { | 413 | { |
341 | double now; | ||
342 | double ret = 0.0; | 414 | double ret = 0.0; |
343 | 415 | ||
344 | EINA_MAIN_LOOP_CHECK_RETURN_VAL(0.0); | 416 | ECORE_TIMER_CHECK(timer) ret; |
345 | _ecore_lock(); | 417 | eo_do(timer, ecore_obj_timer_pending_get(&ret)); |
418 | return ret; | ||
419 | } | ||
346 | 420 | ||
347 | if (!ECORE_MAGIC_CHECK(timer, ECORE_MAGIC_TIMER)) | 421 | static void |
348 | { | 422 | _timer_pending_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list) |
349 | ECORE_MAGIC_FAIL(timer, ECORE_MAGIC_TIMER, | 423 | { |
350 | "ecore_timer_pending_get"); | 424 | double now; |
351 | goto unlock; | 425 | double *ret = va_arg(*list, double *); |
352 | } | 426 | *ret = 0.0; |
427 | |||
428 | EINA_MAIN_LOOP_CHECK_RETURN; | ||
429 | |||
430 | _ecore_lock(); | ||
431 | Ecore_Timer_Private_Data *timer = _pd; | ||
353 | 432 | ||
354 | now = ecore_time_get(); | 433 | now = ecore_time_get(); |
355 | 434 | ||
356 | if (timer->frozen) | 435 | if (timer->frozen) |
357 | ret = timer->pending; | 436 | *ret = timer->pending; |
358 | else | 437 | else |
359 | ret = timer->at - now; | 438 | *ret = timer->at - now; |
360 | unlock: | ||
361 | _ecore_unlock(); | 439 | _ecore_unlock(); |
362 | return ret; | ||
363 | } | 440 | } |
364 | |||
365 | /** | 441 | /** |
366 | * Pauses a running timer. | 442 | * Pauses a running timer. |
367 | * | 443 | * |
@@ -379,24 +455,26 @@ unlock: | |||
379 | EAPI void | 455 | EAPI void |
380 | ecore_timer_freeze(Ecore_Timer *timer) | 456 | ecore_timer_freeze(Ecore_Timer *timer) |
381 | { | 457 | { |
458 | ECORE_TIMER_CHECK(timer); | ||
459 | eo_do(timer, eo_event_freeze()); | ||
460 | } | ||
461 | |||
462 | static void | ||
463 | _timer_freeze(Eo *obj EINA_UNUSED, void *_pd, va_list *list EINA_UNUSED) | ||
464 | { | ||
382 | double now; | 465 | double now; |
383 | 466 | ||
384 | EINA_MAIN_LOOP_CHECK_RETURN; | 467 | EINA_MAIN_LOOP_CHECK_RETURN; |
385 | _ecore_lock(); | ||
386 | 468 | ||
387 | if (!ECORE_MAGIC_CHECK(timer, ECORE_MAGIC_TIMER)) | 469 | Ecore_Timer_Private_Data *timer = _pd; |
388 | { | 470 | _ecore_lock(); |
389 | ECORE_MAGIC_FAIL(timer, ECORE_MAGIC_TIMER, | ||
390 | "ecore_timer_freeze"); | ||
391 | goto unlock; | ||
392 | } | ||
393 | 471 | ||
394 | /* Timer already frozen */ | 472 | /* Timer already frozen */ |
395 | if (timer->frozen) | 473 | if (timer->frozen) |
396 | goto unlock; | 474 | goto unlock; |
397 | 475 | ||
398 | timers = (Ecore_Timer *)eina_inlist_remove(EINA_INLIST_GET(timers), EINA_INLIST_GET(timer)); | 476 | timers = (Ecore_Timer_Private_Data *)eina_inlist_remove(EINA_INLIST_GET(timers), EINA_INLIST_GET(timer)); |
399 | suspended = (Ecore_Timer *)eina_inlist_prepend(EINA_INLIST_GET(suspended), EINA_INLIST_GET(timer)); | 477 | suspended = (Ecore_Timer_Private_Data *)eina_inlist_prepend(EINA_INLIST_GET(suspended), EINA_INLIST_GET(timer)); |
400 | 478 | ||
401 | now = ecore_time_get(); | 479 | now = ecore_time_get(); |
402 | 480 | ||
@@ -423,26 +501,28 @@ unlock: | |||
423 | EAPI void | 501 | EAPI void |
424 | ecore_timer_thaw(Ecore_Timer *timer) | 502 | ecore_timer_thaw(Ecore_Timer *timer) |
425 | { | 503 | { |
504 | ECORE_TIMER_CHECK(timer); | ||
505 | eo_do(timer, eo_event_thaw()); | ||
506 | } | ||
507 | |||
508 | static void | ||
509 | _timer_thaw(Eo *obj, void *_pd, va_list *list EINA_UNUSED) | ||
510 | { | ||
426 | double now; | 511 | double now; |
427 | 512 | ||
428 | EINA_MAIN_LOOP_CHECK_RETURN; | 513 | EINA_MAIN_LOOP_CHECK_RETURN; |
429 | _ecore_lock(); | 514 | Ecore_Timer_Private_Data *timer = _pd; |
430 | 515 | ||
431 | if (!ECORE_MAGIC_CHECK(timer, ECORE_MAGIC_TIMER)) | 516 | _ecore_lock(); |
432 | { | ||
433 | ECORE_MAGIC_FAIL(timer, ECORE_MAGIC_TIMER, | ||
434 | "ecore_timer_thaw"); | ||
435 | goto unlock; | ||
436 | } | ||
437 | 517 | ||
438 | /* Timer not frozen */ | 518 | /* Timer not frozen */ |
439 | if (!timer->frozen) | 519 | if (!timer->frozen) |
440 | goto unlock; | 520 | goto unlock; |
441 | 521 | ||
442 | suspended = (Ecore_Timer *)eina_inlist_remove(EINA_INLIST_GET(suspended), EINA_INLIST_GET(timer)); | 522 | suspended = (Ecore_Timer_Private_Data *)eina_inlist_remove(EINA_INLIST_GET(suspended), EINA_INLIST_GET(timer)); |
443 | now = ecore_time_get(); | 523 | now = ecore_time_get(); |
444 | 524 | ||
445 | _ecore_timer_set(timer, timer->pending + now, timer->in, timer->func, timer->data); | 525 | _ecore_timer_set(obj, timer->pending + now, timer->in, timer->func, timer->data); |
446 | unlock: | 526 | unlock: |
447 | _ecore_unlock(); | 527 | _ecore_unlock(); |
448 | } | 528 | } |
@@ -512,52 +592,50 @@ _ecore_timer_loop_add(double in, | |||
512 | Ecore_Task_Cb func, | 592 | Ecore_Task_Cb func, |
513 | const void *data) | 593 | const void *data) |
514 | { | 594 | { |
515 | double now; | ||
516 | Ecore_Timer *timer = NULL; | 595 | Ecore_Timer *timer = NULL; |
596 | timer = eo_add_custom(MY_CLASS, _ecore_parent, ecore_timer_loop_constructor(in, func, data)); | ||
597 | eo_unref(timer); | ||
517 | 598 | ||
518 | if (!func) return timer; | ||
519 | if (in < 0.0) in = 0.0; | ||
520 | timer = ecore_timer_calloc(1); | ||
521 | if (!timer) return timer; | ||
522 | ECORE_MAGIC_SET(timer, ECORE_MAGIC_TIMER); | ||
523 | now = ecore_loop_time_get(); | ||
524 | |||
525 | #ifdef WANT_ECORE_TIMER_DUMP | ||
526 | timer->timer_bt_num = backtrace((void **)(timer->timer_bt), | ||
527 | ECORE_TIMER_DEBUG_BT_NUM); | ||
528 | #endif | ||
529 | _ecore_timer_set(timer, now + in, in, func, (void *)data); | ||
530 | return timer; | 599 | return timer; |
531 | } | 600 | } |
532 | 601 | ||
533 | EAPI void | 602 | EAPI void |
534 | _ecore_timer_delay(Ecore_Timer *timer, | 603 | _ecore_timer_delay(Ecore_Timer *obj, |
535 | double add) | 604 | double add) |
536 | { | 605 | { |
606 | Ecore_Timer_Private_Data *timer = eo_data_get(obj, MY_CLASS); | ||
607 | |||
537 | if (timer->frozen) | 608 | if (timer->frozen) |
538 | { | 609 | { |
539 | timer->pending += add; | 610 | timer->pending += add; |
540 | } | 611 | } |
541 | else | 612 | else |
542 | { | 613 | { |
543 | timers = (Ecore_Timer *)eina_inlist_remove(EINA_INLIST_GET(timers), EINA_INLIST_GET(timer)); | 614 | timers = (Ecore_Timer_Private_Data *)eina_inlist_remove(EINA_INLIST_GET(timers), EINA_INLIST_GET(timer)); |
544 | _ecore_timer_set(timer, timer->at + add, timer->in, timer->func, timer->data); | 615 | _ecore_timer_set(obj, timer->at + add, timer->in, timer->func, timer->data); |
545 | } | 616 | } |
546 | } | 617 | } |
547 | 618 | ||
548 | void * | 619 | void * |
549 | _ecore_timer_del(Ecore_Timer *timer) | 620 | _ecore_timer_del(Ecore_Timer *obj) |
550 | { | 621 | { |
622 | Ecore_Timer_Private_Data *timer = eo_data_get(obj, MY_CLASS); | ||
623 | |||
551 | if (timer->frozen && !timer->references) | 624 | if (timer->frozen && !timer->references) |
552 | { | 625 | { |
553 | void *data = timer->data; | 626 | void *data = timer->data; |
554 | 627 | ||
555 | suspended = (Ecore_Timer *)eina_inlist_remove(EINA_INLIST_GET(suspended), EINA_INLIST_GET(timer)); | 628 | suspended = (Ecore_Timer_Private_Data *)eina_inlist_remove(EINA_INLIST_GET(suspended), EINA_INLIST_GET(timer)); |
556 | 629 | ||
557 | if (timer->delete_me) | 630 | if (timer->delete_me) |
558 | timers_delete_me--; | 631 | timers_delete_me--; |
559 | 632 | ||
560 | ecore_timer_mp_free(timer); | 633 | eo_parent_set(obj, NULL); |
634 | |||
635 | if (eo_destructed_is(obj)) | ||
636 | eo_manual_free(obj); | ||
637 | else | ||
638 | eo_manual_free_set(obj, EINA_FALSE); | ||
561 | return data; | 639 | return data; |
562 | } | 640 | } |
563 | 641 | ||
@@ -567,23 +645,45 @@ _ecore_timer_del(Ecore_Timer *timer) | |||
567 | return timer->data; | 645 | return timer->data; |
568 | } | 646 | } |
569 | 647 | ||
648 | static void | ||
649 | _destructor(Eo *obj, void *_pd, va_list *list EINA_UNUSED) | ||
650 | { | ||
651 | Ecore_Timer_Private_Data *pd = _pd; | ||
652 | |||
653 | if (!pd->delete_me) | ||
654 | { | ||
655 | pd->delete_me = 1; | ||
656 | timers_delete_me++; | ||
657 | } | ||
658 | |||
659 | eo_do_super(obj, eo_destructor()); | ||
660 | } | ||
661 | |||
570 | void | 662 | void |
571 | _ecore_timer_shutdown(void) | 663 | _ecore_timer_shutdown(void) |
572 | { | 664 | { |
573 | Ecore_Timer *timer; | 665 | Ecore_Timer_Private_Data *timer; |
574 | 666 | ||
575 | while ((timer = timers)) | 667 | while ((timer = timers)) |
576 | { | 668 | { |
577 | timers = (Ecore_Timer *)eina_inlist_remove(EINA_INLIST_GET(timers), EINA_INLIST_GET(timers)); | 669 | timers = (Ecore_Timer_Private_Data *)eina_inlist_remove(EINA_INLIST_GET(timers), EINA_INLIST_GET(timers)); |
578 | ECORE_MAGIC_SET(timer, ECORE_MAGIC_NONE); | 670 | |
579 | ecore_timer_mp_free(timer); | 671 | eo_parent_set(timer->obj, NULL); |
672 | if (eo_destructed_is(timer->obj)) | ||
673 | eo_manual_free(timer->obj); | ||
674 | else | ||
675 | eo_manual_free_set(timer->obj, EINA_FALSE); | ||
580 | } | 676 | } |
581 | 677 | ||
582 | while ((timer = suspended)) | 678 | while ((timer = suspended)) |
583 | { | 679 | { |
584 | suspended = (Ecore_Timer *)eina_inlist_remove(EINA_INLIST_GET(suspended), EINA_INLIST_GET(suspended)); | 680 | suspended = (Ecore_Timer_Private_Data *)eina_inlist_remove(EINA_INLIST_GET(suspended), EINA_INLIST_GET(suspended)); |
585 | ECORE_MAGIC_SET(timer, ECORE_MAGIC_NONE); | 681 | |
586 | ecore_timer_mp_free(timer); | 682 | eo_parent_set(timer->obj, NULL); |
683 | if (eo_destructed_is(timer->obj)) | ||
684 | eo_manual_free(timer->obj); | ||
685 | else | ||
686 | eo_manual_free_set(timer->obj, EINA_FALSE); | ||
587 | } | 687 | } |
588 | 688 | ||
589 | timer_current = NULL; | 689 | timer_current = NULL; |
@@ -592,15 +692,15 @@ _ecore_timer_shutdown(void) | |||
592 | void | 692 | void |
593 | _ecore_timer_cleanup(void) | 693 | _ecore_timer_cleanup(void) |
594 | { | 694 | { |
595 | Ecore_Timer *l; | 695 | Ecore_Timer_Private_Data *l; |
596 | int in_use = 0, todo = timers_delete_me, done = 0; | 696 | int in_use = 0, todo = timers_delete_me, done = 0; |
597 | 697 | ||
598 | if (!timers_delete_me) return; | 698 | if (!timers_delete_me) return; |
599 | for (l = timers; l; ) | 699 | for (l = timers; l; ) |
600 | { | 700 | { |
601 | Ecore_Timer *timer = l; | 701 | Ecore_Timer_Private_Data *timer = l; |
602 | 702 | ||
603 | l = (Ecore_Timer *)EINA_INLIST_GET(l)->next; | 703 | l = (Ecore_Timer_Private_Data *)EINA_INLIST_GET(l)->next; |
604 | if (timer->delete_me) | 704 | if (timer->delete_me) |
605 | { | 705 | { |
606 | if (timer->references) | 706 | if (timer->references) |
@@ -608,9 +708,13 @@ _ecore_timer_cleanup(void) | |||
608 | in_use++; | 708 | in_use++; |
609 | continue; | 709 | continue; |
610 | } | 710 | } |
611 | timers = (Ecore_Timer *)eina_inlist_remove(EINA_INLIST_GET(timers), EINA_INLIST_GET(timer)); | 711 | timers = (Ecore_Timer_Private_Data *)eina_inlist_remove(EINA_INLIST_GET(timers), EINA_INLIST_GET(timer)); |
612 | ECORE_MAGIC_SET(timer, ECORE_MAGIC_NONE); | 712 | |
613 | ecore_timer_mp_free(timer); | 713 | eo_parent_set(timer->obj, NULL); |
714 | if (eo_destructed_is(timer->obj)) | ||
715 | eo_manual_free(timer->obj); | ||
716 | else | ||
717 | eo_manual_free_set(timer->obj, EINA_FALSE); | ||
614 | timers_delete_me--; | 718 | timers_delete_me--; |
615 | done++; | 719 | done++; |
616 | if (timers_delete_me == 0) return; | 720 | if (timers_delete_me == 0) return; |
@@ -618,9 +722,9 @@ _ecore_timer_cleanup(void) | |||
618 | } | 722 | } |
619 | for (l = suspended; l; ) | 723 | for (l = suspended; l; ) |
620 | { | 724 | { |
621 | Ecore_Timer *timer = l; | 725 | Ecore_Timer_Private_Data *timer = l; |
622 | 726 | ||
623 | l = (Ecore_Timer *)EINA_INLIST_GET(l)->next; | 727 | l = (Ecore_Timer_Private_Data *)EINA_INLIST_GET(l)->next; |
624 | if (timer->delete_me) | 728 | if (timer->delete_me) |
625 | { | 729 | { |
626 | if (timer->references) | 730 | if (timer->references) |
@@ -628,9 +732,13 @@ _ecore_timer_cleanup(void) | |||
628 | in_use++; | 732 | in_use++; |
629 | continue; | 733 | continue; |
630 | } | 734 | } |
631 | suspended = (Ecore_Timer *)eina_inlist_remove(EINA_INLIST_GET(suspended), EINA_INLIST_GET(timer)); | 735 | suspended = (Ecore_Timer_Private_Data *)eina_inlist_remove(EINA_INLIST_GET(suspended), EINA_INLIST_GET(timer)); |
632 | ECORE_MAGIC_SET(timer, ECORE_MAGIC_NONE); | 736 | |
633 | ecore_timer_mp_free(timer); | 737 | eo_parent_set(timer->obj, NULL); |
738 | if (eo_destructed_is(timer->obj)) | ||
739 | eo_manual_free(timer->obj); | ||
740 | else | ||
741 | eo_manual_free_set(timer->obj, EINA_FALSE); | ||
634 | timers_delete_me--; | 742 | timers_delete_me--; |
635 | done++; | 743 | done++; |
636 | if (timers_delete_me == 0) return; | 744 | if (timers_delete_me == 0) return; |
@@ -650,7 +758,7 @@ _ecore_timer_cleanup(void) | |||
650 | void | 758 | void |
651 | _ecore_timer_enable_new(void) | 759 | _ecore_timer_enable_new(void) |
652 | { | 760 | { |
653 | Ecore_Timer *timer; | 761 | Ecore_Timer_Private_Data *timer; |
654 | 762 | ||
655 | if (!timers_added) return; | 763 | if (!timers_added) return; |
656 | timers_added = 0; | 764 | timers_added = 0; |
@@ -660,10 +768,10 @@ _ecore_timer_enable_new(void) | |||
660 | int | 768 | int |
661 | _ecore_timers_exists(void) | 769 | _ecore_timers_exists(void) |
662 | { | 770 | { |
663 | Ecore_Timer *timer = timers; | 771 | Ecore_Timer_Private_Data *timer = timers; |
664 | 772 | ||
665 | while ((timer) && (timer->delete_me)) | 773 | while ((timer) && (timer->delete_me)) |
666 | timer = (Ecore_Timer *)EINA_INLIST_GET(timer)->next; | 774 | timer = (Ecore_Timer_Private_Data *)EINA_INLIST_GET(timer)->next; |
667 | 775 | ||
668 | return !!timer; | 776 | return !!timer; |
669 | } | 777 | } |
@@ -671,29 +779,37 @@ _ecore_timers_exists(void) | |||
671 | static inline Ecore_Timer * | 779 | static inline Ecore_Timer * |
672 | _ecore_timer_first_get(void) | 780 | _ecore_timer_first_get(void) |
673 | { | 781 | { |
674 | Ecore_Timer *timer = timers; | 782 | Ecore_Timer *ret = NULL; |
783 | Ecore_Timer_Private_Data *timer = timers; | ||
675 | 784 | ||
676 | while ((timer) && ((timer->delete_me) || (timer->just_added))) | 785 | while ((timer) && ((timer->delete_me) || (timer->just_added))) |
677 | timer = (Ecore_Timer *)EINA_INLIST_GET(timer)->next; | 786 | timer = (Ecore_Timer_Private_Data *)EINA_INLIST_GET(timer)->next; |
678 | 787 | ||
679 | return timer; | 788 | if (timer) |
789 | ret = timer->obj; | ||
790 | return ret; | ||
680 | } | 791 | } |
681 | 792 | ||
682 | static inline Ecore_Timer * | 793 | static inline Ecore_Timer * |
683 | _ecore_timer_after_get(Ecore_Timer *base) | 794 | _ecore_timer_after_get(Ecore_Timer *obj) |
684 | { | 795 | { |
685 | Ecore_Timer *timer = (Ecore_Timer *)EINA_INLIST_GET(base)->next; | 796 | Ecore_Timer *ret = NULL; |
686 | Ecore_Timer *valid_timer = NULL; | 797 | Ecore_Timer_Private_Data *base = eo_data_get(obj, MY_CLASS); |
798 | |||
799 | Ecore_Timer_Private_Data *timer = (Ecore_Timer_Private_Data *)EINA_INLIST_GET(base)->next; | ||
800 | Ecore_Timer_Private_Data *valid_timer = NULL; | ||
687 | double maxtime = base->at + precision; | 801 | double maxtime = base->at + precision; |
688 | 802 | ||
689 | while ((timer) && (timer->at < maxtime)) | 803 | while ((timer) && (timer->at < maxtime)) |
690 | { | 804 | { |
691 | if (!((timer->delete_me) || (timer->just_added))) | 805 | if (!((timer->delete_me) || (timer->just_added))) |
692 | valid_timer = timer; | 806 | valid_timer = timer; |
693 | timer = (Ecore_Timer *)EINA_INLIST_GET(timer)->next; | 807 | timer = (Ecore_Timer_Private_Data *)EINA_INLIST_GET(timer)->next; |
694 | } | 808 | } |
695 | 809 | ||
696 | return valid_timer; | 810 | if (valid_timer) |
811 | ret = valid_timer->obj; | ||
812 | return ret; | ||
697 | } | 813 | } |
698 | 814 | ||
699 | double | 815 | double |
@@ -701,13 +817,16 @@ _ecore_timer_next_get(void) | |||
701 | { | 817 | { |
702 | double now; | 818 | double now; |
703 | double in; | 819 | double in; |
704 | Ecore_Timer *first, *second; | 820 | Ecore_Timer *first_obj, *second_obj; |
821 | Ecore_Timer_Private_Data *first; | ||
822 | |||
823 | first_obj = _ecore_timer_first_get(); | ||
824 | if (!first_obj) return -1; | ||
705 | 825 | ||
706 | first = _ecore_timer_first_get(); | 826 | second_obj = _ecore_timer_after_get(first_obj); |
707 | if (!first) return -1; | 827 | if (second_obj) first_obj = second_obj; |
708 | 828 | ||
709 | second = _ecore_timer_after_get(first); | 829 | first = eo_data_get(first_obj, MY_CLASS); |
710 | if (second) first = second; | ||
711 | 830 | ||
712 | now = ecore_loop_time_get(); | 831 | now = ecore_loop_time_get(); |
713 | in = first->at - now; | 832 | in = first->at - now; |
@@ -716,12 +835,13 @@ _ecore_timer_next_get(void) | |||
716 | } | 835 | } |
717 | 836 | ||
718 | static inline void | 837 | static inline void |
719 | _ecore_timer_reschedule(Ecore_Timer *timer, | 838 | _ecore_timer_reschedule(Ecore_Timer *obj, |
720 | double when) | 839 | double when) |
721 | { | 840 | { |
841 | Ecore_Timer_Private_Data *timer = eo_data_get(obj, MY_CLASS); | ||
722 | if ((timer->delete_me) || (timer->frozen)) return; | 842 | if ((timer->delete_me) || (timer->frozen)) return; |
723 | 843 | ||
724 | timers = (Ecore_Timer *)eina_inlist_remove(EINA_INLIST_GET(timers), EINA_INLIST_GET(timer)); | 844 | timers = (Ecore_Timer_Private_Data *)eina_inlist_remove(EINA_INLIST_GET(timers), EINA_INLIST_GET(timer)); |
725 | 845 | ||
726 | /* if the timer would have gone off more than 15 seconds ago, | 846 | /* if the timer would have gone off more than 15 seconds ago, |
727 | * assume that the system hung and set the timer to go off | 847 | * assume that the system hung and set the timer to go off |
@@ -733,9 +853,9 @@ _ecore_timer_reschedule(Ecore_Timer *timer, | |||
733 | * really slow within the main loop. | 853 | * really slow within the main loop. |
734 | */ | 854 | */ |
735 | if ((timer->at + timer->in) < (when - 15.0)) | 855 | if ((timer->at + timer->in) < (when - 15.0)) |
736 | _ecore_timer_set(timer, when + timer->in, timer->in, timer->func, timer->data); | 856 | _ecore_timer_set(obj, when + timer->in, timer->in, timer->func, timer->data); |
737 | else | 857 | else |
738 | _ecore_timer_set(timer, timer->at + timer->in, timer->in, timer->func, timer->data); | 858 | _ecore_timer_set(obj, timer->at + timer->in, timer->in, timer->func, timer->data); |
739 | } | 859 | } |
740 | 860 | ||
741 | /* assume that we hold the ecore lock when entering this function */ | 861 | /* assume that we hold the ecore lock when entering this function */ |
@@ -753,7 +873,7 @@ _ecore_timer_expired_call(double when) | |||
753 | if (!timers) return 0; | 873 | if (!timers) return 0; |
754 | if (last_check > when) | 874 | if (last_check > when) |
755 | { | 875 | { |
756 | Ecore_Timer *timer; | 876 | Ecore_Timer_Private_Data *timer; |
757 | /* User set time backwards */ | 877 | /* User set time backwards */ |
758 | EINA_INLIST_FOREACH(timers, timer) timer->at -= (last_check - when); | 878 | EINA_INLIST_FOREACH(timers, timer) timer->at -= (last_check - when); |
759 | } | 879 | } |
@@ -762,19 +882,19 @@ _ecore_timer_expired_call(double when) | |||
762 | if (!timer_current) | 882 | if (!timer_current) |
763 | { | 883 | { |
764 | /* regular main loop, start from head */ | 884 | /* regular main loop, start from head */ |
765 | timer_current = timers; | 885 | timer_current = timers; |
766 | } | 886 | } |
767 | else | 887 | else |
768 | { | 888 | { |
769 | /* recursive main loop, continue from where we were */ | 889 | /* recursive main loop, continue from where we were */ |
770 | Ecore_Timer *timer_old = timer_current; | 890 | Ecore_Timer_Private_Data *timer_old = timer_current; |
771 | timer_current = (Ecore_Timer *)EINA_INLIST_GET(timer_current)->next; | 891 | timer_current = (Ecore_Timer_Private_Data *)EINA_INLIST_GET(timer_current)->next; |
772 | _ecore_timer_reschedule(timer_old, when); | 892 | _ecore_timer_reschedule(timer_old->obj, when); |
773 | } | 893 | } |
774 | 894 | ||
775 | while (timer_current) | 895 | while (timer_current) |
776 | { | 896 | { |
777 | Ecore_Timer *timer = timer_current; | 897 | Ecore_Timer_Private_Data *timer = timer_current; |
778 | 898 | ||
779 | if (timer->at > when) | 899 | if (timer->at > when) |
780 | { | 900 | { |
@@ -784,33 +904,35 @@ _ecore_timer_expired_call(double when) | |||
784 | 904 | ||
785 | if ((timer->just_added) || (timer->delete_me)) | 905 | if ((timer->just_added) || (timer->delete_me)) |
786 | { | 906 | { |
787 | timer_current = (Ecore_Timer *)EINA_INLIST_GET(timer_current)->next; | 907 | timer_current = (Ecore_Timer_Private_Data *)EINA_INLIST_GET(timer_current)->next; |
788 | continue; | 908 | continue; |
789 | } | 909 | } |
790 | 910 | ||
791 | timer->references++; | 911 | timer->references++; |
792 | if (!_ecore_call_task_cb(timer->func, timer->data)) | 912 | if (!_ecore_call_task_cb(timer->func, timer->data)) |
793 | { | 913 | { |
794 | if (!timer->delete_me) _ecore_timer_del(timer); | 914 | if (!timer->delete_me) _ecore_timer_del(timer->obj); |
795 | } | 915 | } |
796 | timer->references--; | 916 | timer->references--; |
797 | 917 | ||
798 | if (timer_current) /* may have changed in recursive main loops */ | 918 | if (timer_current) /* may have changed in recursive main loops */ |
799 | timer_current = (Ecore_Timer *)EINA_INLIST_GET(timer_current)->next; | 919 | timer_current = (Ecore_Timer_Private_Data *)EINA_INLIST_GET(timer_current)->next; |
800 | 920 | ||
801 | _ecore_timer_reschedule(timer, when); | 921 | _ecore_timer_reschedule(timer->obj, when); |
802 | } | 922 | } |
803 | return 0; | 923 | return 0; |
804 | } | 924 | } |
805 | 925 | ||
806 | static void | 926 | static void |
807 | _ecore_timer_set(Ecore_Timer *timer, | 927 | _ecore_timer_set(Ecore_Timer *obj, |
808 | double at, | 928 | double at, |
809 | double in, | 929 | double in, |
810 | Ecore_Task_Cb func, | 930 | Ecore_Task_Cb func, |
811 | void *data) | 931 | void *data) |
812 | { | 932 | { |
813 | Ecore_Timer *t2; | 933 | Ecore_Timer_Private_Data *t2; |
934 | |||
935 | Ecore_Timer_Private_Data *timer = eo_data_get(obj, MY_CLASS); | ||
814 | 936 | ||
815 | timers_added = 1; | 937 | timers_added = 1; |
816 | timer->at = at; | 938 | timer->at = at; |
@@ -826,12 +948,12 @@ _ecore_timer_set(Ecore_Timer *timer, | |||
826 | { | 948 | { |
827 | if (timer->at > t2->at) | 949 | if (timer->at > t2->at) |
828 | { | 950 | { |
829 | timers = (Ecore_Timer *)eina_inlist_append_relative(EINA_INLIST_GET(timers), EINA_INLIST_GET(timer), EINA_INLIST_GET(t2)); | 951 | timers = (Ecore_Timer_Private_Data *)eina_inlist_append_relative(EINA_INLIST_GET(timers), EINA_INLIST_GET(timer), EINA_INLIST_GET(t2)); |
830 | return; | 952 | return; |
831 | } | 953 | } |
832 | } | 954 | } |
833 | } | 955 | } |
834 | timers = (Ecore_Timer *)eina_inlist_prepend(EINA_INLIST_GET(timers), EINA_INLIST_GET(timer)); | 956 | timers = (Ecore_Timer_Private_Data *)eina_inlist_prepend(EINA_INLIST_GET(timers), EINA_INLIST_GET(timer)); |
835 | } | 957 | } |
836 | 958 | ||
837 | #ifdef WANT_ECORE_TIMER_DUMP | 959 | #ifdef WANT_ECORE_TIMER_DUMP |
@@ -845,3 +967,50 @@ _ecore_timer_cmp(const void *d1, | |||
845 | return (int)((t1->in - t2->in) * 100); | 967 | return (int)((t1->in - t2->in) * 100); |
846 | } | 968 | } |
847 | #endif | 969 | #endif |
970 | |||
971 | static void | ||
972 | _class_constructor(Eo_Class *klass) | ||
973 | { | ||
974 | const Eo_Op_Func_Description func_desc[] = { | ||
975 | EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR), _constructor), | ||
976 | EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DESTRUCTOR), _destructor), | ||
977 | |||
978 | EO_OP_FUNC(ECORE_TIMER_ID(ECORE_TIMER_SUB_ID_CONSTRUCTOR), _timer_constructor), | ||
979 | EO_OP_FUNC(ECORE_TIMER_ID(ECORE_TIMER_SUB_ID_LOOP_CONSTRUCTOR), _timer_loop_constructor), | ||
980 | EO_OP_FUNC(ECORE_TIMER_ID(ECORE_TIMER_SUB_ID_INTERVAL_SET), _timer_interval_set), | ||
981 | EO_OP_FUNC(ECORE_TIMER_ID(ECORE_TIMER_SUB_ID_INTERVAL_GET), _timer_interval_get), | ||
982 | |||
983 | EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_EVENT_FREEZE), _timer_freeze), | ||
984 | EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_EVENT_THAW), _timer_thaw), | ||
985 | |||
986 | EO_OP_FUNC(ECORE_TIMER_ID(ECORE_TIMER_SUB_ID_DELAY), _timer_delay), | ||
987 | EO_OP_FUNC(ECORE_TIMER_ID(ECORE_TIMER_SUB_ID_RESET), _timer_reset), | ||
988 | EO_OP_FUNC(ECORE_TIMER_ID(ECORE_TIMER_SUB_ID_PENDING_GET), _timer_pending_get), | ||
989 | EO_OP_FUNC_SENTINEL | ||
990 | }; | ||
991 | |||
992 | eo_class_funcs_set(klass, func_desc); | ||
993 | } | ||
994 | |||
995 | static const Eo_Op_Description op_desc[] = { | ||
996 | EO_OP_DESCRIPTION(ECORE_TIMER_SUB_ID_CONSTRUCTOR, "Creates a timer to call the given function in the given period of time."), | ||
997 | EO_OP_DESCRIPTION(ECORE_TIMER_SUB_ID_LOOP_CONSTRUCTOR, "Creates a timer to call the given function in the given period of time."), | ||
998 | EO_OP_DESCRIPTION(ECORE_TIMER_SUB_ID_INTERVAL_SET, "Change the interval the timer ticks of."), | ||
999 | EO_OP_DESCRIPTION(ECORE_TIMER_SUB_ID_INTERVAL_GET, "Get the interval the timer ticks on."), | ||
1000 | EO_OP_DESCRIPTION(ECORE_TIMER_SUB_ID_DELAY, "Add some delay for the next occurrence of a timer."), | ||
1001 | EO_OP_DESCRIPTION(ECORE_TIMER_SUB_ID_RESET, "Reset a timer to its full interval"), | ||
1002 | EO_OP_DESCRIPTION(ECORE_TIMER_SUB_ID_PENDING_GET, "Get the pending time regarding a timer."), | ||
1003 | EO_OP_DESCRIPTION_SENTINEL | ||
1004 | }; | ||
1005 | static const Eo_Class_Description class_desc = { | ||
1006 | EO_VERSION, | ||
1007 | MY_CLASS_NAME, | ||
1008 | EO_CLASS_TYPE_REGULAR, | ||
1009 | EO_CLASS_DESCRIPTION_OPS(&ECORE_TIMER_BASE_ID, op_desc, ECORE_TIMER_SUB_ID_LAST), | ||
1010 | NULL, | ||
1011 | sizeof(Ecore_Timer_Private_Data), | ||
1012 | _class_constructor, | ||
1013 | NULL | ||
1014 | }; | ||
1015 | |||
1016 | EO_DEFINE_CLASS(ecore_timer_class_get, &class_desc, EO_BASE_CLASS, NULL) | ||