[erlang-questions] NIF Callback Pids

Daniel Goertzen daniel.goertzen@REDACTED
Tue Sep 29 21:43:31 CEST 2015


I recall doing that about a year ago and having a lot of trouble supporting
exits from the Erlang side and exits from the thread side.  Reviewing this
code again today reveals that I was just confused about a few things and
missed some easy fixes. :/  I guess the only thing callback pids could
offer is higher messaging performance to NIF land by virtue of skipping the
message copy to the proxy process and also the serialization imposed by the
proxy process.  A high performance logger might find this useful.


On Tue, Sep 29, 2015 at 1:49 PM Roger Lipscombe <roger@REDACTED>
wrote:

> On 29 September 2015 at 15:55, Daniel Goertzen
> <daniel.goertzen@REDACTED> wrote:
> > I love the Erlang NIF API, but one thing I’ve missed is a nice way to
> send
> > messages into NIF code.
>
> You can do this by simply having an Erlang process that calls the NIF
> when it receives a message:
>
> init(Args) ->
>     This = my_nif:init(Args),
>     State = #state { this = This },
>     {ok, State}.
>
> handle_info(Info, #state { this = This } = State) ->
>     my_nif:info(This, Info),
>     {noreply, State}.
>
> ...etc.
>
>  It works pretty well for us. Is there any reason you don't want to do
> that?
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20150929/4c7ea40b/attachment.htm>


More information about the erlang-questions mailing list