- Timestamp:
- Dec 11, 2008, 10:21:13 PM (16 years ago)
- Branches:
- master, debian, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
- Children:
- 80a465c
- Parents:
- ca1fc33a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
select.c
rca1fc33a r58d1f8a 3 3 static const char fileIdent[] = "$Id: select.c 894 2008-01-17 07:13:44Z asedeno $"; 4 4 5 int _owl_select_timer_cmp(owl_timer *t1, owl_timer *t2 , void *data) {5 int _owl_select_timer_cmp(owl_timer *t1, owl_timer *t2) { 6 6 return t1->time - t2->time; 7 7 } 8 8 9 int _owl_select_timer_eq(owl_timer *t1, owl_timer *t2 , void *data) {9 int _owl_select_timer_eq(owl_timer *t1, owl_timer *t2) { 10 10 return t1 == t2; 11 11 } … … 14 14 { 15 15 owl_timer *t = owl_malloc(sizeof(owl_timer)); 16 G Sequence*timers = owl_global_get_timerlist(&g);16 GList **timers = owl_global_get_timerlist(&g); 17 17 18 18 t->time = time(NULL) + after; … … 21 21 t->data = data; 22 22 23 g_sequence_insert_sorted(timers, t,24 (GCompareDataFunc)_owl_select_timer_cmp, NULL);23 *timers = g_list_insert_sorted(*timers, t, 24 (GCompareFunc)_owl_select_timer_cmp); 25 25 return t; 26 26 } … … 28 28 void owl_select_remove_timer(owl_timer *t) 29 29 { 30 GSequenceIter *it = g_sequence_search(owl_global_get_timerlist(&g), 31 t, (GCompareDataFunc)_owl_select_timer_eq, NULL); 32 if(!g_sequence_iter_is_end(it) && 33 g_sequence_get(it) == t) { 30 GList **timers = owl_global_get_timerlist(&g); 31 if (t && g_list_find(*timers, t)) { 32 *timers = g_list_remove(*timers, t); 34 33 owl_free(t); 35 g_sequence_remove(it);36 34 } 37 35 } … … 40 38 { 41 39 time_t now = time(NULL); 42 G SequenceIter *it = g_sequence_get_begin_iter(owl_global_get_timerlist(&g));43 44 while( !g_sequence_iter_is_end(it)) {45 owl_timer *t = g_sequence_get(it);40 GList **timers = owl_global_get_timerlist(&g); 41 42 while(*timers) { 43 owl_timer *t = (*timers)->data; 46 44 void (*cb)(struct _owl_timer *, void *); 47 45 void *data; … … 56 54 if(t->interval > 0) { 57 55 t->time = now + t->interval; 58 g_sequence_sort_changed(it, (GCompareDataFunc)_owl_select_timer_cmp, NULL); 56 *timers = g_list_remove(*timers, t); 57 *timers = g_list_insert_sorted(*timers, t, 58 (GCompareFunc)_owl_select_timer_cmp); 59 59 } else { 60 60 owl_select_remove_timer(t); … … 64 64 /* Do the callback */ 65 65 cb(t, data); 66 67 it = g_sequence_get_begin_iter(owl_global_get_timerlist(&g)); 68 } 69 70 if(g_sequence_iter_is_end(it)) { 66 } 67 68 if(*timers) { 69 owl_timer *t = (*timers)->data; 70 timeout->tv_sec = t->time - now; 71 if (timeout->tv_sec > 60) 72 timeout->tv_sec = 60; 73 } else { 71 74 timeout->tv_sec = 60; 72 } else {73 owl_timer *t = g_sequence_get(it);74 timeout->tv_sec = t->time - now;75 75 } 76 76
Note: See TracChangeset
for help on using the changeset viewer.