[erlang-questions] enif_keep_resource, enif_release_resource and thread safety

Vincent Siliakus zambal@REDACTED
Mon Aug 8 15:13:09 CEST 2016

Thanks for the confirmation! In that case I think the issue I encountered
was that a resource was released before a keep call and thereby
unexpectedly deleted, but I'll investigate to be sure what was happening.


On Sat, Aug 6, 2016 at 4:16 AM, Daniel Goertzen <daniel.goertzen@REDACTED>

> Those functions have their own synchronization so no need to add your own.
> The usage case you describe sound fine.
> On Thu, Aug 4, 2016, 03:41 Vincent Siliakus <zambal@REDACTED> wrote:
>> Hi,
>> Does anyone know if synchronization is needed when one calls
>> enif_keep_resource in nif functions and enif_release_resource in a nif
>> background thread? Or in other words: is the ref counting that is used
>> under the hood thread safe?
>> I ask this because during some refactoring of code in the LMDB driver I'm
>> developing at https://github.com/zambal/elmdb I stumbled upon a problem
>> that might have been caused by unsynchronized calls to these functions.
>> However,  when I searched github for other code that uses resources , I
>> couldn't find examples that use synchronization, but that might be because
>> it's simply not needed in those libraries, so I'm still not sure.
>> Thanks,
>> Vincent
>> _______________________________________________
>> 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/20160808/3d70fbe5/attachment.htm>

More information about the erlang-questions mailing list