chickadee » srfi-18 » thread-sleep!

(thread-sleep! timeout) procedure

The current thread waits until the timeout is reached. This blocks the thread only if timeout represents a point in the future. It is an error for timeout to be #f. thread-sleep! returns an unspecified value.

    ; a clock with a gradual drift:
 
    (let loop ((x 1))
      (thread-sleep! 1)
      (write x)
      (loop (+ x 1)))
 
    ; a clock with no drift:
 
    (let ((start (time->seconds (current-time)))
      (let loop ((x 1))
        (thread-sleep! (seconds->time (+ x start)))
        (write x)
        (loop (+ x 1))))