Changeset 36927 in project


Ignore:
Timestamp:
11/25/18 18:00:03 (2 weeks ago)
Author:
svnwiki
Message:

Anonymous wiki edit for IP [109.70.100.18]: Improve example code.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wiki/eggref/4/simple-timer

    r36907 r36927  
    116116Best practice using thread signals:
    117117<enscript highlight="scheme">
    118 (handle-exceptions
    119  ex
    120  (cond
    121   ((timer-condition? ex)
    122   ;; clean up after timeout here
    123   #t)
    124   (else ex))
    125  ...
    126  (let* ((task (register-timer-task! 1 (current-thread)) )
    127         (result (do-some-work-within-time-limit)))
    128    (cancel-timer-task! task)
     118(let ((task #f))
     119  (handle-exceptions
     120   ex
     121   (cond
     122    ((timer-condition? ex)
     123     ;; clean up after timeout here
     124     #t)
     125    (else
     126     (or (cancel-timer-task! task)
     127         (error "too late to cancel, that's bad"))
     128     ex))
    129129   ...
    130    result)
     130   (set! task (register-timer-task! 1 (current-thread)))
     131   (let ((result (do-some-work-within-time-limit)))
     132     (cancel-timer-task! task)
     133     ...
     134     result)))
    131135</enscript>
    132136
Note: See TracChangeset for help on using the changeset viewer.