[erlang-questions] What is the proper way of sending messages to pid from enif thread?

Sergej Jurecko sergej.jurecko@REDACTED
Tue Jul 7 18:40:47 CEST 2015


I just copy ErlNifPid to a C structure and use it from another thread. The environment used on that other thread was created with enif_alloc_env. 

Sergej

From:  <erlang-questions-bounces@REDACTED> on behalf of Max Lapshin
Date:  Tuesday 7 July 2015 18:30
To:  Erlang-Questions Questions
Subject:  [erlang-questions] What is the proper way of sending messages to pid from enif thread?

Hi.


I've created thread in nif function.  When I create thread, I know pid of caller:

  ErlNifPid self;
  enif_self(env, &self);


But later in thread I need to create some environment and send message to this pid.

What is the proper way to save this ErlNifPid in C structure so that code in other thread will be able to send messages.

And as far as I understand, I need to call  enif_alloc_env in that thread?

_______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://erlang.org/mailman/listinfo/erlang-questions 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20150707/d02f09b9/attachment.htm>


More information about the erlang-questions mailing list