9 #include "ecore_private.h"
11 static int throttle_val = 0;
14 * @addtogroup Ecore_Throttle_Group Ecore Throttle functions
20 * Increase throttle amount
22 * This will increase or decrease (if @p amount is positive or negative) the
23 * amount of "voluntary throttling" ecore will do to its main loop while
24 * running. This is intended to be used to limit animations and wakeups when
25 * in a strict power management state. The higher the current throttle value
26 * (which can be retrieved by ecore_throttle_get() ), the more throttling
27 * takes place. If the current throttle value is 0, then no throttling takes
30 * The value represents how long the ecore main loop will sleep (in seconds)
31 * before it goes into a fully idle state waiting for events, input or
32 * timing events to wake it up. For example, if the current throttle level
33 * is 0.5, then after every time the main loop cycles and goes into idle
34 * affter processing all events, the main loop will explicitly sleep for 0.5
35 * seconds before sitting and waiting for incoming events or timeouts, thus
36 * preventing animation, async IO and network handling etc. for that period
37 * of time. Of course these events, data and timeouts will be buffered,
38 * thus not losing anything, simply delaying when they get handled by the
43 * void enter_powersave(void) {
44 * ecore_throttle_adjust(0.2);
45 * printf("Now at throttle level: %1.3f\n", ecore_throttle_get());
48 * void enter_deep_powersave(void) {
49 * ecore_throttle_adjust(0.5);
50 * printf("Now at throttle level: %1.3f\n", ecore_throttle_get());
53 * void exit_powersave(void) {
54 * ecore_throttle_adjust(-0.2);
55 * printf("Now at throttle level: %1.3f\n", ecore_throttle_get());
58 * void exit_deep_powersave(void) {
59 * ecore_throttle_adjust(-0.5);
60 * printf("Now at throttle level: %1.3f\n", ecore_throttle_get());
64 * @param amount Amount (in seconds) to adjust by
67 ecore_throttle_adjust(double amount)
69 EINA_MAIN_LOOP_CHECK_RETURN;
70 int adj = amount * 1000000.0;
72 if (throttle_val < 0) throttle_val = 0;
76 * Get current throttle level
78 * This gets the current throttling level, which can be adjusted by
79 * ecore_throttle_adjust(). The value is in seconds. Please see
80 * ecore_throttle_adjust() for more information.
82 * @return The current throttle level
85 ecore_throttle_get(void)
87 EINA_MAIN_LOOP_CHECK_RETURN_VAL(0.0);
88 return (double)throttle_val / 1000000.0;
98 if (throttle_val <= 0) return;