[erlang-questions] Calling (equivalent of) erlang:send_after/3 from a NIF?
Tue Oct 30 15:03:16 CET 2018
On Mon, Oct 29, 2018, at 5:24 PM, Roger Lipscombe wrote:
> On 29 October 2018 at 19:38, Nathaniel Waisbrot
> <nathaniel@REDACTED> wrote:>> Is the idea that your NIF would pause the system for some time and
>> then send>> its message and unpause the system?
> I've got a reactor-style thing going on inside my NIF, where I service> a large number of timers and sockets. We're hitting scalability issues> with our current implementation, so I'm evaluating alternatives.
> Since this is already in a NIF, I'd like to experiment with replacing> the socket polling with Erlang's enif_select, because I suspect it'll> be more scalable -- I'd like to find out, anyway. The plan is that, on> receiving the message from enif_select, I can quickly dip back into
> NIF-land and service the relevant socket.
> Some of these sockets are actually libcurl-driven, and one of the
> things that libcurl wants is for us to start a timer. I was hoping
> that there'd be an equivalent of enif_select, but for timers (i.e.
> enif_send_after). We also service a large number of non-curl timers,
> and so I was hoping to use Erlang's timer implementation for these as> well.
Maybe you could use a port driver for this.
I played a little bit with creating a port driver to run Perl in a
parallel thread, but I ultimately found it more trouble than I was
willing to deal with. (The port driver code is complex and the
documentation is difficult)
I did not try creating a C node, but maybe that would actually have been
easier; I assume that with a C node I wouldn't have been crashing my run-
time as frequently.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions