<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 25 May 2017 at 18:07, Felix Gallo <span dir="ltr"><<a href="mailto:felixgallo@gmail.com" target="_blank">felixgallo@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Rather than dive into the details of another process, wouldn't it be more erlang to use enif_consume_timeslice (<a href="http://erlang.org/doc/man/erl_nif.html#enif_consume_timeslice" target="_blank">http://erlang.org/doc/man/<wbr>erl_nif.html#enif_consume_<wbr>timeslice</a>) and/or dirty nifs and just let the scheduler do its thing?</div></blockquote><div><br></div><div>This stuff's running on a background thread. Specifically, it's running a Squirrel VM (<a href="http://squirrel-lang.org">squirrel-lang.org</a>) on a background thread. Some of the calls in the squirrel code result in enif_send to the accompanying (1:1) Erlang process. I'd like the squirrel to (briefly) pause[1] if the Erlang process has too many messages in its queue.</div><div><br></div><div>[1] not actually pause; we're running 10s of thousands of these on a pool of background threads, we want the one that's calling enif_send too frequently to yield, *exactly* the same as an Erlang process would do.</div></div></div></div>