Contains this quote
"Blocking I/O will block all threads, except for some socket operations (see the section about the
tcp
unit). An exception is the read-eval-print loop on UNIX platforms:
waiting for input will not block other threads, provided the current
input port reads input from a console."
When I try running the following code:
(use srfi-18)
(define var 0)
(define thread (make-thread (lambda () (let loop ()
(set! var (add1 var))
(loop)))))
(thread-start! thread)
(read-line)
(print var)
No matter how long I wait before hitting enter, result printed is always 0. Although I'm fairly inexperienced, I believe this means that the thread is not running, due to chicken blocking on the call to read-line as it waits for my input. The thread is never run, and never increments var.
As for the library busy waiting, yes I suppose it does. The procedures reader-ready? and writer-ready? use file-select with a timeout of 0 from the posix unit under the hood. thread-wait-for-i/o! or file-select could be used instead of these procedures to allow a thread or the entire process to not busy wait. I was thinking of use cases such as games, where there is work to be done, regardless of weather a client is currently communicating, in which case it might be better to periodically check if input or output is ready, and if not, do something else. Is there a better way to handle those cases than busy waiting?
As I said, I'm fairly inexperienced and would appreciate any feedback you have to offer.