[Top][All Lists]

[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.
> 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:


> 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))
(thread-start! thread)
(print var)

But yeah, the current situation is still a big mess.  Sorry :(


Attachment: signature.asc
Description: Digital signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]