summaryrefslogtreecommitdiff
path: root/legacy/ecore/src/lib/ecore/ecore_poll.c
diff options
context:
space:
mode:
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>2010-05-19 09:16:37 +0000
committerMike Blumenkrantz <michael.blumenkrantz@gmail.com>2010-05-19 09:16:37 +0000
commitd55e116a4e4e08178e734719959b16965f5abd0b (patch)
tree499841244e5562019a00f13a4cd34f1f6b94e406 /legacy/ecore/src/lib/ecore/ecore_poll.c
parent5259fb8d83f0eeff3866d14c05bc800fef727b3b (diff)
added functions for changing/getting a poller's poll interval: ecore_poller_poller_interval_(set|get) along with dox for them
surprisingly enough they seem to work! SVN revision: 49002
Diffstat (limited to 'legacy/ecore/src/lib/ecore/ecore_poll.c')
-rw-r--r--legacy/ecore/src/lib/ecore/ecore_poll.c88
1 files changed, 82 insertions, 6 deletions
diff --git a/legacy/ecore/src/lib/ecore/ecore_poll.c b/legacy/ecore/src/lib/ecore/ecore_poll.c
index 09ae89925f..dd1528aeb0 100644
--- a/legacy/ecore/src/lib/ecore/ecore_poll.c
+++ b/legacy/ecore/src/lib/ecore/ecore_poll.c
@@ -316,6 +316,82 @@ ecore_poller_add(Ecore_Poller_Type type __UNUSED__, int interval, int (*func) (v
316} 316}
317 317
318/** 318/**
319 * Changes the polling interval rate of @p poller.
320 *
321 * @param poller The Ecore_Poller to change the interval of
322 * @param interval The tick interval to set; must be a power of 2 but <= 32768
323 * @return Returns true on success, false on failure
324 *
325 * This allows the changing of a poller's polling interval. It is useful when you want to alter
326 * a poll rate without deleting and re-creating a poller.
327 * @ingroup Ecore_Poller_Group
328 */
329EAPI Eina_Bool
330ecore_poller_poller_interval_set(Ecore_Poller *poller, int interval)
331{
332 int ibit;
333
334 if (!ECORE_MAGIC_CHECK(poller, ECORE_MAGIC_POLLER))
335 {
336 ECORE_MAGIC_FAIL(poller, ECORE_MAGIC_POLLER,
337 "ecore_poller_poller_interval_set");
338 return 0;
339 }
340
341 /* interval MUST be a power of 2, so enforce it */
342 if (interval < 1) interval = 1;
343 ibit = -1;
344 while (interval != 0)
345 {
346 ibit++;
347 interval >>= 1;
348 }
349 /* only allow up to 32768 - i.e. ibit == 15, so limit it */
350 if (ibit > 15) ibit = 15;
351 /* if interval specified is the same as interval set, return true without wasting time */
352 if (poller->ibit == ibit)
353 return 1;
354 pollers[poller->ibit] = (Ecore_Poller *) eina_inlist_remove(EINA_INLIST_GET(pollers[poller->ibit]), EINA_INLIST_GET(poller));
355 poller->ibit = ibit;
356 pollers[poller->ibit] = (Ecore_Poller *) eina_inlist_prepend(EINA_INLIST_GET(pollers[poller->ibit]), EINA_INLIST_GET(poller));
357 if (poller_walking)
358 just_added_poller++;
359 else
360 _ecore_poller_next_tick_eval();
361 return 1;
362}
363
364/**
365 * Gets the polling interval rate of @p poller.
366 *
367 * @param poller The Ecore_Poller to change the interval of
368 * @return Returns the interval, in ticks, that @p poller polls at
369 *
370 * This returns a poller's polling interval, or 0 on error.
371 * @ingroup Ecore_Poller_Group
372 */
373EAPI int
374ecore_poller_poller_interval_get(Ecore_Poller *poller)
375{
376 int ibit, interval = 1;
377
378 if (!ECORE_MAGIC_CHECK(poller, ECORE_MAGIC_POLLER))
379 {
380 ECORE_MAGIC_FAIL(poller, ECORE_MAGIC_POLLER,
381 "ecore_poller_poller_interval_get");
382 return 0;
383 }
384
385 ibit = poller->ibit;
386 while (ibit != 0)
387 {
388 ibit--;
389 interval <<= 1;
390 }
391 return interval;
392}
393
394/**
319 * Delete the specified poller from the timer list. 395 * Delete the specified poller from the timer list.
320 * @param poller The poller to delete. 396 * @param poller The poller to delete.
321 * @return The data pointer set for the timer when @ref ecore_poller_add was 397 * @return The data pointer set for the timer when @ref ecore_poller_add was
@@ -332,18 +408,18 @@ ecore_poller_del(Ecore_Poller *poller)
332 408
333 if (!ECORE_MAGIC_CHECK(poller, ECORE_MAGIC_POLLER)) 409 if (!ECORE_MAGIC_CHECK(poller, ECORE_MAGIC_POLLER))
334 { 410 {
335 ECORE_MAGIC_FAIL(poller, ECORE_MAGIC_POLLER, 411 ECORE_MAGIC_FAIL(poller, ECORE_MAGIC_POLLER,
336 "ecore_poller_del"); 412 "ecore_poller_del");
337 return NULL; 413 return NULL;
338 } 414 }
339 /* we are walking the poller list - a bad idea to remove from it while 415 /* we are walking the poller list - a bad idea to remove from it while
340 * walking it, so just flag it as delete_me and come back to it after 416 * walking it, so just flag it as delete_me and come back to it after
341 * the loop has finished */ 417 * the loop has finished */
342 if (poller_walking > 0) 418 if (poller_walking > 0)
343 { 419 {
344 poller_delete_count++; 420 poller_delete_count++;
345 poller->delete_me = 1; 421 poller->delete_me = 1;
346 return poller->data; 422 return poller->data;
347 } 423 }
348 /* not in loop so safe - delete immediately */ 424 /* not in loop so safe - delete immediately */
349 data = poller->data; 425 data = poller->data;