chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] Asynchronous I/O Egg Release


From: Robert Smiley
Subject: Re: [Chicken-users] Asynchronous I/O Egg Release
Date: Thu, 7 Jul 2016 19:06:32 -0600

In all honesty, I hadn't used the make-input-port procedure before. It didn't occur to me to use that to make a nonblocking input port. Your code snippet seems to solve the problem quite a bit better than my egg does.

Is open-input-file*/nonblock in a currently released egg?

On Thu, Jul 7, 2016 at 6:04 AM, Kristian Lein-Mathisen <address@hidden> wrote:
I don't know how useful this is, but I though I'd throw in a test I use as we've encountered this a few times as well in the posix egg:


(use posix srfi-18)

(define mythread
  (thread-start!
   (lambda ()
     (let loop ()
       (define start (current-milliseconds))
       (thread-sleep! 0.1)
       (define elap (- (current-milliseconds) start))
       (if (> elap 500) ;; the 0.1 second sleep took > 0.5 seconds!
           (print "OBS! elap = " elap)
           (loop))))))

(print "cmd: sleep 1 ; echo hi" (with-input-from-pipe "sleep 1.5 ; echo hi" read-string))
(thread-join! mythread)

$ csi -version
Version 4.9.0.1 (stability/4.9.0) (rev 8b3189b)
linux-unix-gnu-x86-64 [ 64bit manyargs dload ptables ]
bootstrapped 2014-06-07
$ csi -s blocking-io-test.scm 
cmd: sleep 1 ; echo hihi

OBS! elap = 1512.0

And this is a code-snippet we use to solve it.


K.

On Fri, Jul 1, 2016 at 6:53 PM, Matt Welland <address@hidden> wrote:


On Fri, Jul 1, 2016 at 3:11 AM, Andy Bennett <address@hidden> wrote:
Hi,

> And of course, reads of files on the file
> system never block at all

A read from a file can block when the operating system needs to go to
disk for the data. This happens when the buffer empties and it cannot be
refilled before the next read call.

I don't know if it applies to this discussion but read blocking can be quite a pain when a network fileserver such as NFS goes offline. It would be nice if other threads would continue so that the program could detect the issue and potentially take appropriate action such as let the user know *why* the program is hung.
 





Regards,
@ndy

--
address@hidden
http://www.ashurst.eu.org/
0290 DA75 E982 7D99 A51F  E46A 387A 7695 7EBA 75FF


_______________________________________________
Chicken-users mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/chicken-users


_______________________________________________
Chicken-users mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/chicken-users



_______________________________________________
Chicken-users mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/chicken-users



reply via email to

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