[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] non-blocking (read)
From: |
Daishi Kato |
Subject: |
Re: [Chicken-users] non-blocking (read) |
Date: |
Thu, 21 Jul 2005 09:49:02 +0900 |
User-agent: |
Wanderlust/2.15.1 (Almost Unreal) Emacs/21.4 Mule/5.0 (SAKAKI) |
At Wed, 20 Jul 2005 09:39:32 +0200,
felix winkelmann wrote:
> Absolutely. You can try out Thomas' suggestions. Alternatively, this is the
> code
> from srfi-18.scm, that makes the repl non-blocking:
>
> (set! ##sys#read-prompt-hook
> (let ([old ##sys#read-prompt-hook]
> [thread-yield! thread-yield!] )
> (lambda ()
> (when (or (##sys#fudge 12) (##sys#tty-port? ##sys#standard-input))
> (old)
> (##sys#thread-block-for-i/o! ##sys#current-thread 0 #t)
> (thread-yield!)))) ) )
>
> Here is an adaption that might work:
>
> (use srfi-18)
>
> (thread-start!
> (lambda ()
> (let loop ((i 1))
> (thread-sleep! 1)
> (print "[" i "]")
> (loop (add1 i)))))
>
> (define (my-repl)
> (let loop ()
> (print* "my-server> ")
> (##sys#thread-block-for-i/o! (current-thread) 0 #t)
> (thread-yield!)
> (pp `(READ: ,(read)))
> (loop) ) )
>
> (my-repl)
Just adding two lines
(##sys#thread-block-for-i/o! (current-thread) 0 #t)
(thread-yield!)
really works fine in the interpreter. thanks!
Also, I was trying to make an egg for nonblocking stdin,
by copying lines from tcp.scm.
However lack of the experience of making eggs makes me hard to debug it.
Overall, I'm still not sure how to debug scheme code.
Attatched file is non-woking code, just in case somebody can have a look.
Daishi
nbstdin.scm
Description: Binary data
- [Chicken-users] non-blocking (read), Daishi Kato, 2005/07/15
- Re: [Chicken-users] non-blocking (read), felix winkelmann, 2005/07/17
- Re: [Chicken-users] non-blocking (read), Daishi Kato, 2005/07/18
- Re: [Chicken-users] non-blocking (read), felix winkelmann, 2005/07/19
- Re: [Chicken-users] non-blocking (read), Daishi Kato, 2005/07/19
- Re: [Chicken-users] non-blocking (read), Thomas Chust, 2005/07/19
- Re: [Chicken-users] non-blocking (read), felix winkelmann, 2005/07/20
- Re: [Chicken-users] non-blocking (read), Daishi Kato, 2005/07/20
- Re: [Chicken-users] non-blocking (read),
Daishi Kato <=