Changeset 11979 in project


Ignore:
Timestamp:
09/22/08 23:54:38 (11 years ago)
Author:
felix winkelmann
Message:

refactoring of timeout-list removal, also used in ##sys#thread-kill\! (thanks to Joerg Wittenberger)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • chicken/trunk/scheduler.scm

    r11918 r11979  
    3737        ##sys#remove-from-ready-queue ##sys#unblock-threads-for-i/o ##sys#force-primordial
    3838        ##sys#fdset-input-set ##sys#fdset-output-set ##sys#fdset-clear
    39         ##sys#fdset-select-timeout ##sys#fdset-restore
     39        ##sys#fdset-select-timeout ##sys#fdset-restore ##sys#remove-from-timeout-list
    4040        ##sys#clear-i/o-state-for-thread!)
    4141  (foreign-declare #<<EOF
     
    213213(define ##sys#timeout-list '())
    214214
     215(define (##sys#remove-from-timeout-list t)
     216  (let loop ((l ##sys#timeout-list) (prev #f))
     217    (if (null? l)
     218        l
     219        (let ((h (##sys#slot l 0))
     220              (r (##sys#slot l 1)))
     221          (if (eq? (##sys#slot h 1) t)
     222              (if prev
     223                  (set-cdr! prev r)
     224                  (set! ##sys#timeout-list r))
     225              (loop r l))))))
     226
    215227(define (##sys#thread-block-for-timeout! t tm)
    216228  (dbg t " blocks for " tm)
     
    242254  (##sys#setislot t 11 #f)
    243255  (##sys#setislot t 8 '())
     256  (##sys#remove-from-timeout-list t)
    244257  (let ([rs (##sys#slot t 12)])
    245258    (unless (null? rs)
     
    439452(define (##sys#thread-unblock! t)
    440453  (when (eq? 'blocked (##sys#slot t 3))
    441     (set! ##sys#timeout-list
    442       (let loop ((l ##sys#timeout-list))
    443         (if (null? l)
    444             l
    445             (let ((h (##sys#slot l 0)))
    446               (if (eq? (##sys#slot h 1) t)
    447                   (##sys#slot l 1)
    448                   (cons h (loop (##sys#slot l 1))))))))
     454    (##sys#remove-from-timeout-list t)
    449455    (set! ##sys#fd-list
    450456      (let loop ([fdl ##sys#fd-list])
Note: See TracChangeset for help on using the changeset viewer.