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

From: Corey Sweeney (corey.sweeney at gmail.com)
Date: Sun Mar 11 14:38:37 EDT 2007

I'm getting a wierd phenominon that cycles every 500ms.  does
peek-bytes-avail!* cache it's results for 500ms?

This is my setup:   I'm using

(define data-log-output (open-output-file data-log-filename 'replace))
(file-stream-buffer-mode data-log-output 'none)

to write lines to a file 250 times a second.  I added a "flush", and
everything seems to work ok, as i can "tail -f --sleep-interval=.001
{logfile}" and see the updates happen very quickly

I also use:

(define data-log-input (open-input-file data-log-filename))
(file-stream-buffer-mode data-log-input 'none)

to read the file and each time a new line shows up, transmit it over a
network port with:

(define (ready-to-read? input-port)
  (define dummy (make-bytes 1))
  (define dummy2 (port-progress-evt input-port))
  (not (zero? (peek-bytes-avail!* dummy 0 dummy2 input-port))))

(if (ready-to-read? data-log-input)
   (display (read data-log-input) network-out-port))

it all works, however it only seems to write to the network in a big
pulse about every 500ms.  Does peek-bytes-avail!* ever cache it's
results, and report 0 when it's called, if it was just called
recently?

Corey

-- 
((lambda (y) (y y)) (lambda (y) (y y)))


Posted on the users mailing list.