<!DOCTYPE html>
<html>
<head>
<title></title>
<style type="text/css">p.MsoNormal,p.MsoNoSpacing{margin:0}</style>
</head>
<body><div>On Mon, Oct 29, 2018, at 5:24 PM, Roger Lipscombe wrote:<br></div>
<blockquote type="cite"><div>On 29 October 2018 at 19:38, Nathaniel Waisbrot <<a href="mailto:nathaniel@waisbrot.net">nathaniel@waisbrot.net</a>> wrote:<br></div>
<blockquote><div>Is the idea that your NIF would pause the system for some time and then send<br></div>
<div>its message and unpause the system?<br></div>
</blockquote><div><br></div>
<div>I've got a reactor-style thing going on inside my NIF, where I service<br></div>
<div>a large number of timers and sockets. We're hitting scalability issues<br></div>
<div>with our current implementation, so I'm evaluating alternatives.<br></div>
<div><br></div>
<div>Since this is already in a NIF, I'd like to experiment with replacing<br></div>
<div>the socket polling with Erlang's enif_select, because I suspect it'll<br></div>
<div>be more scalable -- I'd like to find out, anyway. The plan is that, on<br></div>
<div>receiving the message from enif_select, I can quickly dip back into<br></div>
<div>NIF-land and service the relevant socket.<br></div>
<div><br></div>
<div>Some of these sockets are actually libcurl-driven, and one of the<br></div>
<div>things that libcurl wants is for us to start a timer. I was hoping<br></div>
<div>that there'd be an equivalent of enif_select, but for timers (i.e.<br></div>
<div>enif_send_after). We also service a large number of non-curl timers,<br></div>
<div>and so I was hoping to use Erlang's timer implementation for these as<br></div>
<div>well.<br></div>
</blockquote><div><br></div>
<div><br></div>
<div>Maybe you could use a port driver for this. <a href="http://erlang.org/doc/man/erl_driver.html">http://erlang.org/doc/man/erl_driver.html</a><br></div>
<div><br></div>
<div>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)<br></div>
<div><br></div>
<div>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.<br></div>
</body>
</html>