[erlang-questions] NIF ErlNifEnv thread safety?

Daniel Goertzen daniel.goertzen@REDACTED
Thu Apr 23 20:09:21 CEST 2015


Now that my coffee-induced ADHD has subsided I now understand the original
text.  The word "This" was the part that made things fuzzy for me.  Maybe
something like the following...

"Process independent environments and associated terms that are shared
between threads also require explicit synchronization."

In any case, my question is answered.

Cheers,
Dan.

On Thu, Apr 23, 2015 at 11:20 AM, Sverker Eriksson <
sverker.eriksson@REDACTED> wrote:

>
>
> On 04/23/2015 05:54 PM, Daniel Goertzen wrote:
>
> Can multiple threads safely use the same process-independent ErlNifEnv?
> The documentation isn't clear to me.  From
> http://www.erlang.org/doc/man/erl_nif.html ...
>
>  "Threads and concurrency
>
> A NIF is thread-safe without any explicit synchronization as long as it
> acts as a pure function and only reads the supplied arguments. As soon as
> you write towards a shared state either through static variables or
> enif_priv_data you need to supply your own explicit synchronization. This
> includes terms in process independent environments that are shared between
> threads. Resource objects will also require synchronization if you treat
> them as mutable."
>
>
>   Would it be clearer if "terms in" was removed from the third sentence:
>
> "This includes process independent environments that are shared between
> threads."
>
>
> /Sverker, Erlang/OTP
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20150423/5798311d/attachment.htm>


More information about the erlang-questions mailing list