[erlang-questions] enif_get_resource and reference counting
John Doe
donpedrothird@REDACTED
Sun Jan 10 11:09:36 CET 2016
Thank you! Thought so, but was not 100% sure.
2016-01-10 0:20 GMT+03:00 Daniel Goertzen <daniel.goertzen@REDACTED>:
> enif_get_resource() does not increase the reference count. You can think
> of the term representing the resource as counting as a reference, so as
> long as the term and its environment are alive then the resource will not
> be destroyed. In the example you have above you can skip the
> keep()/release() because the resource term w/environment keeps it alive.
>
> On Sat, Jan 9, 2016 at 12:12 AM John Doe <donpedrothird@REDACTED> wrote:
>
>> Hi,
>> Does successful call of enif_get_resource increase reference counter on a
>> resource, like enif_keep_resource does?
>> Or It is neccessary to do
>> enif_get_resource(...);
>> enif_keep_resource(...);
>> ...some job...
>> enif_release_resource(...);
>>
>> And if it does not increment the counter, can the resource become
>> destroyed in the another thread between calls to enif_get_resource and
>> enif_keep_resource?
>> I'm afraid of race condition there.
>> _______________________________________________
>> 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/20160110/0d8f4346/attachment.htm>
More information about the erlang-questions
mailing list