Cool! The open-fd-input-port is a great function. Inotify cannot handle subtrees. I will try to make it more convenience. I plan to make a tool like guard - https://github.com/guard/guard
It's useful to run unit tests while some files are changed. Thanks, Haiwei On 30 January 2013 20:52, Laurent <[email protected]> wrote: > For the record, Kevin Tew's function makes it easy to use: > https://github.com/kazzmir/x11-racket/blob/master/fd.rkt > > For example, that's what I use in my own version of libinotify FFI: > https://github.com/Metaxal/linux-tools/blob/master/inotify.rkt > > Laurent > > > On Wed, Jan 30, 2013 at 12:28 PM, Tim Brown <[email protected]> wrote: > >> Resend... original (and previous resend!) sent from an address not >> valid for the list. >> >> ---------- Forwarded message ---------- >> From: Tim Brown <[email protected]> >> Date: 30 January 2013 10:01 >> Subject: Re: [racket] How to invoke a blocking foreign function >> without blocking whole racket? >> To: Haiwei Zhou <[email protected]> >> Cc: [email protected] >> >> >> There are internal FFI calls: scheme_make_fd_input_port and >> scheme_make_fd_output_port, documented in >> >> http://docs.racket-lang.org/inside/Ports_and_the_Filesystem.html?q=to%20port#(idx._(gentag._480._(lib._scribblings/inside/inside..scrbl)))<http://docs.racket-lang.org/inside/Ports_and_the_Filesystem.html?q=to%20port#%28idx._%28gentag._480._%28lib._scribblings/inside/inside..scrbl%29%29%29> >> >> If you would normally be able to poll (or select) from the port, then >> a little bit of work will allow you to tie your IO closer to the >> racket events system. >> >> There are more involved variants, I've mostly only needed this level >> of access at the racket level; servicing the known-to-be ready fd is >> done by your FFI library. >> >> Tim >> >> On 30 Jan 2013 09:44, "Haiwei Zhou" <[email protected]> wrote: >> > >> > Finally, I figured out the callback from this letter: >> http://lists.racket-lang.org/users/archive/2010-July/040409.html . I >> wish I red this letter early. >> > >> > After realized that the foreign function blocks the caller thread, I >> used dynamic-place to create worker thread. The code is here : >> https://github.com/highfly22/alert/blob/master/inotify.rkt >> > >> > Racket is amazing simple after you know the bloody details. >> > >> > Haiwei >> > >> > >> > On 30 January 2013 14:23, Haiwei Zhou <[email protected]> wrote: >> >> >> >> 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 >> > >> > >> > >> > ____________________ >> > Racket Users list: >> > http://lists.racket-lang.org/users >> > >> ____________________ >> Racket Users list: >> http://lists.racket-lang.org/users >> > >
____________________ Racket Users list: http://lists.racket-lang.org/users

