[erlang-questions] erlang nif resource & thread safety

Benoit Chesneau <>
Mon May 2 11:47:47 CEST 2016


I had a look in the doc but I can't figure exactly how much a nif resource
could live outside the process that created it, ie. how others processes
can write/read to it and how to make sure the resource will be accessible
to them.

So I created a nif resource that have the following properties:
- it  is ref counted, each time a call is made to it, the counter is
incremented and decremented when it return.
- the process that create it will live until the vm is closed
- write and reads to the resource are thread safe, at least the functions
that use resource

For now I was thinking to share this resources between others processes via
an ETS table. But I am wondering if instead it shouldn't be safer to makes
all the call via a nif. With the result of creating some kind of
bottleneck. Is there any other pattern I should follow? How does ETS which
in my understanding is a nif?

- benoît
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20160502/e0522202/attachment.html>


More information about the erlang-questions mailing list