[erlang-questions] Calling (equivalent of) erlang:send_after/3 from a NIF?

Roger Lipscombe roger@REDACTED
Tue Oct 30 16:04:30 CET 2018

On 30 October 2018 at 14:03, Nathaniel Waisbrot <nathaniel@REDACTED> wrote:
> Maybe you could use a port driver for this.
> http://erlang.org/doc/man/erl_driver.html

The port driver API does appear to be slightly "richer" in the
specific timer/select area, but the API looks kinda complicated, and
we've already got a NIF, so...

> 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.

With a C node, I'd have to reimplement (or find) a suitable timer
implementation. We've got a timer/select implementation; it just
doesn't scale as well as I'd like, so I was hoping to use Erlang's
(hopefully battle-hardened and scalable) implementation. I've got a
couple more easy wins I can make to our existing implementation, but
then we're going to have to take a long, hard look at it.

As it is, our NIF is already running in its own Erlang node, so I'm
not *that* bothered about crashing the runtime[1], not that we *do*
crash the runtime (not since over a year ago, anyway).

[1] See, I said I was aware of the risks of NIFs ;-)

More information about the erlang-questions mailing list