[plt-scheme] Re: peek-bytes-avail!* caching results???

From: Daniel Yoo (dyoo at cs.wpi.edu)
Date: Mon Mar 12 12:38:35 EDT 2007


On Mon, 12 Mar 2007, Corey Sweeney wrote:

> I found my issue.  peek-bytes-avail!* works fine.  The issue was that
> the system clock ran the opposite way then I would have expected.
> example:
>
>>  (require (lib "19.ss" "srfi"))
>>  (time-nanosecond (current-time))(time-nanosecond
>>  (current-time))(time-nanosecond (current-time))
> 2940000
> 2850000
> 2780000


Hi Corey,

Wait: time is constructed from both seconds AND nanoseconds.  I think you 
wanted:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(require (lib "19.ss" "srfi"))

(define (get-nanoseconds)
   (local
       ((define t (current-time))
        (define secs (time-second t))
        (define nanosecs (time-nanosecond t)))
     (+ (* (expt 10 9) secs)
        nanosecs)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


Best of wishes!


Posted on the users mailing list.