summaryrefslogtreecommitdiff
path: root/legacy/ecore/src/lib/ecore/ecore_poll.c
diff options
context:
space:
mode:
authorVincent Torri <vincent.torri@gmail.com>2010-09-30 06:09:20 +0000
committerVincent Torri <vincent.torri@gmail.com>2010-09-30 06:09:20 +0000
commit16263f52cc03ca65151ad8804506415ae4381ccf (patch)
treeb518d6e5e902ba7e9599a1f97b103eb367b1f2bd /legacy/ecore/src/lib/ecore/ecore_poll.c
parent0aaad2d41ec39444306f619606918e6290634183 (diff)
tab--
SVN revision: 52918
Diffstat (limited to '')
-rw-r--r--legacy/ecore/src/lib/ecore/ecore_poll.c152
1 files changed, 76 insertions, 76 deletions
diff --git a/legacy/ecore/src/lib/ecore/ecore_poll.c b/legacy/ecore/src/lib/ecore/ecore_poll.c
index 14679526c6..d5bc6badf5 100644
--- a/legacy/ecore/src/lib/ecore/ecore_poll.c
+++ b/legacy/ecore/src/lib/ecore/ecore_poll.c
@@ -52,21 +52,21 @@ _ecore_poller_next_tick_eval(void)
52 min_interval = -1; 52 min_interval = -1;
53 for (i = 0; i < 15; i++) 53 for (i = 0; i < 15; i++)
54 { 54 {
55 if (pollers[i]) 55 if (pollers[i])
56 { 56 {
57 min_interval = i; 57 min_interval = i;
58 break; 58 break;
59 } 59 }
60 } 60 }
61 if (min_interval < 0) 61 if (min_interval < 0)
62 { 62 {
63 /* no pollers */ 63 /* no pollers */
64 if (timer) 64 if (timer)
65 { 65 {
66 ecore_timer_del(timer); 66 ecore_timer_del(timer);
67 timer = NULL; 67 timer = NULL;
68 } 68 }
69 return; 69 return;
70 } 70 }
71 interval_incr = (1 << min_interval); 71 interval_incr = (1 << min_interval);
72 interval = interval_incr * poll_interval; 72 interval = interval_incr * poll_interval;
@@ -76,28 +76,28 @@ _ecore_poller_next_tick_eval(void)
76 * callback will adjust the timer interval at the end anyway */ 76 * callback will adjust the timer interval at the end anyway */
77 if (at_tick) 77 if (at_tick)
78 { 78 {
79 if (!timer) 79 if (!timer)
80 timer = ecore_timer_add(interval, _ecore_poller_cb_timer, NULL); 80 timer = ecore_timer_add(interval, _ecore_poller_cb_timer, NULL);
81 } 81 }
82 else 82 else
83 { 83 {
84 double t; 84 double t;
85 85
86 if (!timer) 86 if (!timer)
87 timer = ecore_timer_add(interval, _ecore_poller_cb_timer, NULL); 87 timer = ecore_timer_add(interval, _ecore_poller_cb_timer, NULL);
88 else 88 else
89 { 89 {
90 t = ecore_time_get(); 90 t = ecore_time_get();
91 if (interval != poll_cur_interval) 91 if (interval != poll_cur_interval)
92 { 92 {
93 t -= last_tick; /* time since we last ticked */ 93 t -= last_tick; /* time since we last ticked */
94 /* delete the timer and reset it to tick off in the new 94 /* delete the timer and reset it to tick off in the new
95 * time interval. at the tick this will be adjusted */ 95 * time interval. at the tick this will be adjusted */
96 ecore_timer_del(timer); 96 ecore_timer_del(timer);
97 timer = ecore_timer_add(interval - t, 97 timer = ecore_timer_add(interval - t,
98 _ecore_poller_cb_timer, NULL); 98 _ecore_poller_cb_timer, NULL);
99 } 99 }
100 } 100 }
101 } 101 }
102 poll_cur_interval = interval; 102 poll_cur_interval = interval;
103} 103}
@@ -116,9 +116,9 @@ _ecore_poller_cb_timer(void *data __UNUSED__)
116 * 7, 16 etc. up to 32768) */ 116 * 7, 16 etc. up to 32768) */
117 for (i = 0; i < 15; i++) 117 for (i = 0; i < 15; i++)
118 { 118 {
119 poller_counters[i] += interval_incr; 119 poller_counters[i] += interval_incr;
120 /* wrap back to 0 if we exceed out loop count for the counter */ 120 /* wrap back to 0 if we exceed out loop count for the counter */
121 if (poller_counters[i] >= (1 << i)) poller_counters[i] = 0; 121 if (poller_counters[i] >= (1 << i)) poller_counters[i] = 0;
122 } 122 }
123 123
124 just_added_poller = 0; 124 just_added_poller = 0;
@@ -126,49 +126,49 @@ _ecore_poller_cb_timer(void *data __UNUSED__)
126 poller_walking++; 126 poller_walking++;
127 for (i = 0; i < 15; i++) 127 for (i = 0; i < 15; i++)
128 { 128 {
129 /* if the counter is @ 0 - this means that counter "went off" this 129 /* if the counter is @ 0 - this means that counter "went off" this
130 * tick interval, so run all pollers hooked to that counter */ 130 * tick interval, so run all pollers hooked to that counter */
131 if (poller_counters[i] == 0) 131 if (poller_counters[i] == 0)
132 { 132 {
133 EINA_INLIST_FOREACH(pollers[i], poller) 133 EINA_INLIST_FOREACH(pollers[i], poller)
134 { 134 {
135 if (!poller->delete_me) 135 if (!poller->delete_me)
136 { 136 {
137 if (!poller->func(poller->data)) 137 if (!poller->func(poller->data))
138 { 138 {
139 if (!poller->delete_me) 139 if (!poller->delete_me)
140 { 140 {
141 poller->delete_me = 1; 141 poller->delete_me = 1;
142 poller_delete_count++; 142 poller_delete_count++;
143 } 143 }
144 } 144 }
145 } 145 }
146 } 146 }
147 } 147 }
148 } 148 }
149 poller_walking--; 149 poller_walking--;
150 150
151 /* handle deletes afterwards */ 151 /* handle deletes afterwards */
152 if (poller_delete_count > 0) 152 if (poller_delete_count > 0)
153 { 153 {
154 /* FIXME: walk all pollers and remove deleted ones */ 154 /* FIXME: walk all pollers and remove deleted ones */
155 for (i = 0; i < 15; i++) 155 for (i = 0; i < 15; i++)
156 { 156 {
157 for (l = pollers[i]; l;) 157 for (l = pollers[i]; l;)
158 { 158 {
159 poller = l; 159 poller = l;
160 l = (Ecore_Poller *) EINA_INLIST_GET(l)->next; 160 l = (Ecore_Poller *) EINA_INLIST_GET(l)->next;
161 if (poller->delete_me) 161 if (poller->delete_me)
162 { 162 {
163 pollers[i] = (Ecore_Poller *) eina_inlist_remove(EINA_INLIST_GET(pollers[i]), EINA_INLIST_GET(poller)); 163 pollers[i] = (Ecore_Poller *) eina_inlist_remove(EINA_INLIST_GET(pollers[i]), EINA_INLIST_GET(poller));
164 free(poller); 164 free(poller);
165 poller_delete_count--; 165 poller_delete_count--;
166 changes++; 166 changes++;
167 if (poller_delete_count <= 0) break; 167 if (poller_delete_count <= 0) break;
168 } 168 }
169 } 169 }
170 if (poller_delete_count <= 0) break; 170 if (poller_delete_count <= 0) break;
171 } 171 }
172 } 172 }
173 /* if we deleted or added any pollers, then we need to re-evaluate our 173 /* if we deleted or added any pollers, then we need to re-evaluate our
174 * minimum poll interval */ 174 * minimum poll interval */
@@ -294,8 +294,8 @@ ecore_poller_add(Ecore_Poller_Type type __UNUSED__, int interval, Ecore_Task_Cb
294 ibit = -1; 294 ibit = -1;
295 while (interval != 0) 295 while (interval != 0)
296 { 296 {
297 ibit++; 297 ibit++;
298 interval >>= 1; 298 interval >>= 1;
299 } 299 }
300 /* only allow up to 32768 - i.e. ibit == 15, so limit it */ 300 /* only allow up to 32768 - i.e. ibit == 15, so limit it */
301 if (ibit > 15) ibit = 15; 301 if (ibit > 15) ibit = 15;
@@ -433,10 +433,10 @@ _ecore_poller_shutdown(void)
433 433
434 for (i = 0; i < 15; i++) 434 for (i = 0; i < 15; i++)
435 { 435 {
436 while ((poller = pollers[i])) 436 while ((poller = pollers[i]))
437 { 437 {
438 pollers[i] = (Ecore_Poller *) eina_inlist_remove(EINA_INLIST_GET(pollers[i]), EINA_INLIST_GET(pollers[i])); 438 pollers[i] = (Ecore_Poller *) eina_inlist_remove(EINA_INLIST_GET(pollers[i]), EINA_INLIST_GET(pollers[i]));
439 free(poller); 439 free(poller);
440 } 440 }
441 } 441 }
442} 442}