[racket] How to invoke a blocking foreign function without blocking whole racket?

From: Haiwei Zhou (highfly22 at gmail.com)
Date: Wed Jan 30 01:23:50 EST 2013

Hi,

 I try to wrap inotify API. After adding a watcher, I try to read events
from file descriptor. But the racket thread is blocking until the read
operation is done. Here is the definition of read.

(define _read (get-ffi-obj "read" libc (_fun #:async-apply (lambda (f) (f))
                                             #:save-errno 'posix
                                            _fd_t
                                            (output : (_bytes o size))
                                            (size : _uint32)
                                            -> (r : _int32)
                                            -> (values r saved-errno
output))))

I am confused by the term callback. Is the callback called in the racket
thread or another OS thread?

Thanks,
Haiwei
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20130130/aa2f5e0c/attachment.html>

Posted on the users mailing list.