[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] non-blocking (read)
From: |
felix winkelmann |
Subject: |
Re: [Chicken-users] non-blocking (read) |
Date: |
Wed, 20 Jul 2005 09:39:32 +0200 |
On 7/19/05, Daishi Kato <address@hidden> wrote:
>
> Then, I would make a perl script to communicate with "my-http-server"
> and translate the S-expression command to any format,
> but the point is I would like to compile it.
>
> Does this make sense?
>
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)
cheers,
felix
- [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 <=
- Re: [Chicken-users] non-blocking (read), Daishi Kato, 2005/07/20
- Re: [Chicken-users] non-blocking (read), Daishi Kato, 2005/07/20