It's my understanding that if a normal Erlang process does Pid ! Msg, and Pid has a particularly full message queue, then the sending process is penalised (gives up the remainder of its timeslice, e.g.).
Is there any way to implement something similar for enif_send from a NIF?
25 мая 2017 г., в 15:44, Roger Lipscombe <ro...@differentpla.net> написал(а):
_______________________________________________
erlang-questions mailing list
erlang-q...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions
Rather than dive into the details of another process, wouldn't it be more erlang to use enif_consume_timeslice (http://erlang.org/doc/man/erl_nif.html#enif_consume_timeslice) and/or dirty nifs and just let the scheduler do its thing?
If your NIF is running in a process managed by the scheduler,
That way you wouldn't have to reach into the internals of another process to make your own determination, which seems like it'd be a better idea.
Is there any way to implement something similar for enif_send from a NIF?
It is possible to get that information in the current implementation, but it may very well not be possible in future implementations. We don't want to create an API that exposes an implementation detail that may very well change in the future.
If you need that type of back pressure, you should implement your own synchronization mechanism.