<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Why not write a small driver that can watch a number of file descriptors,<div class="">Get fd from a nif pass it to the driver_select_driver may be overkill but fun.</div><div class=""><br class=""></div><div class="">Could be a useful thing.</div><div class=""><br class=""></div><div class="">I am working on something that may someday be capable of doing this,</div><div class="">( <a href="https://github.com/tonyrog/niffed" class="">https://github.com/tonyrog/niffed</a> )</div><div class="">It is a a C library that allow you to call (linked) nif library from driver code,</div><div class="">The marshalling code is actually building VM heap compatible data that </div><div class="">can be processed by the nif code, only by offsetting some pointers :-)</div><div class="">It is even possible to use the same shared object as both nif and driver!</div><div class=""><br class=""></div><div class="">/Tony</div><div class=""><br class=""></div><div class=""><div><blockquote type="cite" class=""><div class="">On 29 jan 2015, at 15:20, Serge Aleynikov <<a href="mailto:serge@aleynikov.org" class="">serge@aleynikov.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Is there a way to hook a file descriptor from within a NIF function to the select/epoll/poll loop managed by the emulator with a callback invoked in the "NIF-land" on activity detected on the file descriptor?</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br class=""></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">I am looking for similar functionality available to NIF functions that is available when writing drivers using driver_select() call (*). More specifically, I have an eventfd file descriptor that I'd like to be notified about without allocating a separate OS thread to poll on that FD and return results by sending a message to a given Erlang Pid.</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br class=""></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Thanks,</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br class=""></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Serge</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br class=""></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">(*) <a href="http://www.erlang.org/doc/man/erl_driver.html#driver_select" class="">http://www.erlang.org/doc/man/erl_driver.html#driver_select</a></div></div>
_______________________________________________<br class="">erlang-questions mailing list<br class=""><a href="mailto:erlang-questions@erlang.org" class="">erlang-questions@erlang.org</a><br class="">http://erlang.org/mailman/listinfo/erlang-questions<br class=""></div></blockquote></div><br class=""></div></body></html>