[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] Asynchronous I/O Egg Release
From: |
Peter Bex |
Subject: |
Re: [Chicken-users] Asynchronous I/O Egg Release |
Date: |
Thu, 30 Jun 2016 20:39:39 +0200 |
User-agent: |
Mutt/1.5.23 (2014-03-12) |
On Thu, Jun 30, 2016 at 12:14:00PM -0600, Robert Smiley wrote:
> Hi guys. I'm not very familiar with the low level details, but the
> documentation for srfi-18 found here.
>
> https://wiki.call-cc.org/man/4/Unit%20srfi-18
>
> 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."
I guess this isn't entirely correct, given your hanging program.
> When I try running the following code:
[code]
> 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.
That's right. A simple way around this is to wrap the port in Parley,
which will make the port nonblocking:
(use srfi-18 parley)
(current-input-port (make-parley-port old)))
(define var 0)
(define thread (make-thread (lambda () (let loop ()
(set! var (add1 var))
(loop)))))
(thread-start! thread)
(read-line)
(print var)
But yeah, the current situation is still a big mess. Sorry :(
Cheers,
Peter
signature.asc
Description: Digital signature
- [Chicken-users] Asynchronous I/O Egg Release, Robert Smiley, 2016/06/29
- Re: [Chicken-users] Asynchronous I/O Egg Release, Mario Domenech Goulart, 2016/06/30
- Re: [Chicken-users] Asynchronous I/O Egg Release, Peter Bex, 2016/06/30
- Re: [Chicken-users] Asynchronous I/O Egg Release, Chris Vine, 2016/06/30
- Re: [Chicken-users] Asynchronous I/O Egg Release, Peter Bex, 2016/06/30
- Re: [Chicken-users] Asynchronous I/O Egg Release, Chris Vine, 2016/06/30
- Re: [Chicken-users] Asynchronous I/O Egg Release, Peter Bex, 2016/06/30
- Re: [Chicken-users] Asynchronous I/O Egg Release, Chris Vine, 2016/06/30
- Re: [Chicken-users] Asynchronous I/O Egg Release, Peter Bex, 2016/06/30
- Re: [Chicken-users] Asynchronous I/O Egg Release, Robert Smiley, 2016/06/30
- Re: [Chicken-users] Asynchronous I/O Egg Release,
Peter Bex <=
- Re: [Chicken-users] Asynchronous I/O Egg Release, Chris Vine, 2016/06/30
- Re: [Chicken-users] Asynchronous I/O Egg Release, Chris Vine, 2016/06/30
- Re: [Chicken-users] Asynchronous I/O Egg Release, John Cowan, 2016/06/30
- Re: [Chicken-users] Asynchronous I/O Egg Release, Chris Vine, 2016/06/30