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

Serge Aleynikov serge@REDACTED
Thu Jan 29 17:37:52 CET 2015


Actually something more simple that only allows for NIF reactivity to file
descriptor events...  I understand that native processes are quite some
time away in the pipeline.

On Thu, Jan 29, 2015 at 10:10 AM, Daniel Goertzen <daniel.goertzen@REDACTED
> wrote:

> You are talking about NIF Native Processes:
> http://www.erlang-factory.com/upload/presentations/377/RickardGreen-NativeInterface.pdf
>
>
>
> On Thu, Jan 29, 2015 at 9:01 AM, Serge Aleynikov <serge@REDACTED>
> wrote:
>
>> Thanks Tony for the tip.  I was hoping there is some other way to call
>> the emulator's internals without resorting to having to implement both a
>> driver and a NIF library for this purpose.  It seems like it's somewhat an
>> oversight in the NIF API design that needs to be addressed - there should
>> be a NIF capable of associating an FD with a callback or else, as you
>> mentioned, the implementation of this becomes more complicated than
>> necessary when integrating with external C libraries.
>>
>> On Thu, Jan 29, 2015 at 9:44 AM, Tony Rogvall <tony@REDACTED> wrote:
>>
>>> 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 )
>>> 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
>>> _______________________________________________
>>> erlang-questions mailing list
>>> erlang-questions@REDACTED
>>> http://erlang.org/mailman/listinfo/erlang-questions
>>>
>>>
>>>
>>
>> _______________________________________________
>> 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/11865b1a/attachment.htm>


More information about the erlang-questions mailing list