[erlang-questions] Accessing private data in a NIF C module

Sverker Eriksson <>
Mon Dec 14 12:19:05 CET 2009


zambal wrote:
> I could not found any information about if one needs to do any manual
> locking when accessing data via enif_get_data(env) in an exported NIF
> function. Does anybody know if this is needed?
>   
Yes, you need to do your own locking on any data structures that you 
introduce yourself and access either through enif_get_data() or static 
variables. The callbacks load, reload, upgrade and unload are however 
thread safe.

I will add more about this in the erl_nif documentation for next release.

/Sverker, Erlang/OTP Ericsson



More information about the erlang-questions mailing list