/[emacs]/emacs/src/atimer.c
ViewVC logotype

Diff of /emacs/src/atimer.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.11 by gerd, Mon Oct 8 09:42:04 2001 UTC revision 1.11.4.1 by miles, Fri Apr 4 06:20:56 2003 UTC
# Line 132  start_atimer (type, time, fn, client_dat Line 132  start_atimer (type, time, fn, client_dat
132      case ATIMER_ABSOLUTE:      case ATIMER_ABSOLUTE:
133        t->expiration = time;        t->expiration = time;
134        break;        break;
135          
136      case ATIMER_RELATIVE:      case ATIMER_RELATIVE:
137        EMACS_GET_TIME (t->expiration);        EMACS_GET_TIME (t->expiration);
138        EMACS_ADD_TIME (t->expiration, t->expiration, time);        EMACS_ADD_TIME (t->expiration, t->expiration, time);
139        break;        break;
140          
141      case ATIMER_CONTINUOUS:      case ATIMER_CONTINUOUS:
142        EMACS_GET_TIME (t->expiration);        EMACS_GET_TIME (t->expiration);
143        EMACS_ADD_TIME (t->expiration, t->expiration, time);        EMACS_ADD_TIME (t->expiration, t->expiration, time);
# Line 151  start_atimer (type, time, fn, client_dat Line 151  start_atimer (type, time, fn, client_dat
151    
152    /* Arrange for a SIGALRM at the time the next atimer is ripe.  */    /* Arrange for a SIGALRM at the time the next atimer is ripe.  */
153    set_alarm ();    set_alarm ();
154      
155    return t;    return t;
156  }  }
157    
# Line 163  cancel_atimer (timer) Line 163  cancel_atimer (timer)
163       struct atimer *timer;       struct atimer *timer;
164  {  {
165    int i;    int i;
166      
167    BLOCK_ATIMERS;    BLOCK_ATIMERS;
168    
169    for (i = 0; i < 2; ++i)    for (i = 0; i < 2; ++i)
170      {      {
171        struct atimer *t, *prev;        struct atimer *t, *prev;
172        struct atimer **list = i ? &stopped_atimers : &atimers;        struct atimer **list = i ? &stopped_atimers : &atimers;
173          
174        /* See if TIMER is active or stopped.  */        /* See if TIMER is active or stopped.  */
175        for (t = *list, prev = NULL; t && t != timer; prev = t, t = t->next)        for (t = *list, prev = NULL; t && t != timer; prev = t, t = t->next)
176          ;          ;
# Line 184  cancel_atimer (timer) Line 184  cancel_atimer (timer)
184              prev->next = t->next;              prev->next = t->next;
185            else            else
186              *list = t->next;              *list = t->next;
187              
188            t->next = free_atimers;            t->next = free_atimers;
189            free_atimers = t;            free_atimers = t;
190            break;            break;
# Line 209  append_atimer_lists (list1, list2) Line 209  append_atimer_lists (list1, list2)
209    else    else
210      {      {
211        struct atimer *p;        struct atimer *p;
212          
213        for (p = list1; p->next; p = p->next)        for (p = list1; p->next; p = p->next)
214          ;          ;
215        p->next = list2;        p->next = list2;
# Line 225  stop_other_atimers (t) Line 225  stop_other_atimers (t)
225       struct atimer *t;       struct atimer *t;
226  {  {
227    BLOCK_ATIMERS;    BLOCK_ATIMERS;
228      
229    if (t)    if (t)
230      {      {
231        struct atimer *p, *prev;        struct atimer *p, *prev;
232          
233        /* See if T is active.  */        /* See if T is active.  */
234        for (p = atimers, prev = 0; p && p != t; p = p->next)        for (p = atimers, prev = 0; p && p != t; p = p->next)
235          ;          ;
# Line 246  stop_other_atimers (t) Line 246  stop_other_atimers (t)
246          /* T is not active.  Let's handle this like T == 0.  */          /* T is not active.  Let's handle this like T == 0.  */
247          t = NULL;          t = NULL;
248      }      }
249      
250    stopped_atimers = append_atimer_lists (atimers, stopped_atimers);    stopped_atimers = append_atimer_lists (atimers, stopped_atimers);
251    atimers = t;    atimers = t;
252    UNBLOCK_ATIMERS;    UNBLOCK_ATIMERS;
# Line 263  run_all_atimers () Line 263  run_all_atimers ()
263      {      {
264        struct atimer *t = atimers;        struct atimer *t = atimers;
265        struct atimer *next;        struct atimer *next;
266          
267        BLOCK_ATIMERS;        BLOCK_ATIMERS;
268        atimers = stopped_atimers;        atimers = stopped_atimers;
269        stopped_atimers = NULL;        stopped_atimers = NULL;
270          
271        while (t)        while (t)
272          {          {
273            next = t->next;            next = t->next;
274            schedule_atimer (t);            schedule_atimer (t);
275            t = next;            t = next;
276          }          }
277          
278        UNBLOCK_ATIMERS;        UNBLOCK_ATIMERS;
279      }      }
280  }  }
# Line 301  set_alarm () Line 301  set_alarm ()
301       must reestablish each time.  */       must reestablish each time.  */
302    signal (SIGALRM, alarm_signal_handler);    signal (SIGALRM, alarm_signal_handler);
303  #endif /* USG */  #endif /* USG */
304      
305    if (atimers)    if (atimers)
306      {      {
307        EMACS_TIME now, time;        EMACS_TIME now, time;
# Line 320  set_alarm () Line 320  set_alarm ()
320            EMACS_SET_SECS (time, 0);            EMACS_SET_SECS (time, 0);
321            EMACS_SET_USECS (time, 1000);            EMACS_SET_USECS (time, 1000);
322          }          }
323          
324        bzero (&it, sizeof it);        bzero (&it, sizeof it);
325        it.it_value = time;        it.it_value = time;
326        setitimer (ITIMER_REAL, &it, 0);        setitimer (ITIMER_REAL, &it, 0);
# Line 350  schedule_atimer (t) Line 350  schedule_atimer (t)
350      prev->next = t;      prev->next = t;
351    else    else
352      atimers = t;      atimers = t;
353      
354    t->next = a;    t->next = a;
355  }  }
356    
# Line 363  alarm_signal_handler (signo) Line 363  alarm_signal_handler (signo)
363       int signo;       int signo;
364  {  {
365    EMACS_TIME now;    EMACS_TIME now;
366      
367    EMACS_GET_TIME (now);    EMACS_GET_TIME (now);
368    pending_atimers = 0;    pending_atimers = 0;
369      
370    while (atimers    while (atimers
371           && (pending_atimers = interrupt_input_blocked) == 0           && (pending_atimers = interrupt_input_blocked) == 0
372           && EMACS_TIME_LE (atimers->expiration, now))           && EMACS_TIME_LE (atimers->expiration, now))
373      {      {
374        struct atimer *t;        struct atimer *t;
375          
376        t = atimers;        t = atimers;
377        atimers = atimers->next;        atimers = atimers->next;
378        t->fn (t);        t->fn (t);
379          
380        if (t->type == ATIMER_CONTINUOUS)        if (t->type == ATIMER_CONTINUOUS)
381          {          {
382            EMACS_ADD_TIME (t->expiration, now, t->interval);            EMACS_ADD_TIME (t->expiration, now, t->interval);
# Line 387  alarm_signal_handler (signo) Line 387  alarm_signal_handler (signo)
387            t->next = free_atimers;            t->next = free_atimers;
388            free_atimers = t;            free_atimers = t;
389          }          }
390          
391        EMACS_GET_TIME (now);        EMACS_GET_TIME (now);
392      }      }
393      
394    set_alarm ();    set_alarm ();
395  }  }
396    

Legend:
Removed from v.1.11  
changed lines
  Added in v.1.11.4.1

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26