[erlang-questions] NIFs and hooking file descriptors to Erlang-manged poll

Tony Rogvall tony@REDACTED
Thu Jan 29 15:44:59 CET 2015


Why not write a small driver that can watch a number of file descriptors,
Get fd from a nif pass it to the driver_select_driver may be overkill but fun.

Could be a useful thing.

I am working on something that may someday be capable of doing this,
( https://github.com/tonyrog/niffed <https://github.com/tonyrog/niffed> )
It is a a C library that allow you to call (linked) nif library from driver code,
The marshalling code is actually building VM heap compatible data that
can be processed by the nif code, only by offsetting some pointers :-)
It is even possible to use the same shared object as both nif and driver!

/Tony

> On 29 jan 2015, at 15:20, Serge Aleynikov <serge@REDACTED> wrote:
> 
> 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?
> 
> 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.
> 
> Thanks,
> 
> Serge
> 
> (*) http://www.erlang.org/doc/man/erl_driver.html#driver_select <http://www.erlang.org/doc/man/erl_driver.html#driver_select>_______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20150129/6155c0c4/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20150129/6155c0c4/attachment.bin>


More information about the erlang-questions mailing list