<div dir="ltr"><div>Finally, I figured out the callback from this letter: <a href="http://lists.racket-lang.org/users/archive/2010-July/040409.html">http://lists.racket-lang.org/users/archive/2010-July/040409.html</a> . I wish I red this letter early.<br>
</div><div><br></div><div>After realized that the foreign function blocks the caller thread, I used <span title="Provided from: racket/place, racket"><span class=""><a class="">dynamic-place</a></span></span><span class=""></span> to create worker thread. The code is here : <a href="https://github.com/highfly22/alert/blob/master/inotify.rkt">https://github.com/highfly22/alert/blob/master/inotify.rkt</a><br>
<br></div><div>Racket is amazing simple after you know the bloody details.<br><br></div><div>Haiwei</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On 30 January 2013 14:23, Haiwei Zhou <span dir="ltr">&lt;<a href="mailto:highfly22@gmail.com" target="_blank">highfly22@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div>Hi,<br><br></div> 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.<br>

<br>(define _read (get-ffi-obj &quot;read&quot; libc (_fun #:async-apply (lambda (f) (f))<br>                                             #:save-errno &#39;posix<br>                                            _fd_t<br>                                            (output : (_bytes o size))<br>

                                            (size : _uint32)<br>                                            -&gt; (r : _int32)<br>                                            -&gt; (values r saved-errno output))))<br></div>

<br></div><div>I am confused by the term callback. Is the callback called in the racket thread or another OS thread?<br><br></div><div>Thanks,<br>Haiwei<br></div></div>
</blockquote></div><br></div>