[erlang-questions] find a nif resource by its nale

Loïc Hoguin essen@REDACTED
Wed Aug 23 07:59:12 CEST 2017


It is my understanding that in OTP 20, magic binaries are gone, and 
references are used instead:

   OTP-14205    Application(s): erts

                All uses of the magic binary kludge has been replaced
                by uses of erlang references.

                A magic binary was presented as an empty binary, but
                actually referred other data internally in the Erlang
                VM. Since they were presented as empty binaries,
                different magic binaries compared as equal, and also
                lost their internal data when passed out of an erlang
                node.

                The new usage of references has not got any of these
                strange semantic issues, and the usage of these
                references has been optimized to give the same
                performance benefits as well as memory usage benefits
                as magic binaries had.

                A couple of examples of previous uses of magic binaries
                are match specifications and NIF resources.

So it sounds like you don't need to do anything?

On 08/22/2017 09:38 PM, Benoit Chesneau wrote:
> I like the idea of not passing a nif resource like ets does (ie passing a ref or a name). A idea on how this could be done in an efficient manner?
> 
> I actually think to use an rw lock and a simple map in the private resource for it. But unsure what I should return on creation. Do we have to return the resource erlang term to keep it associated to the process? or simply creating it in the process will be enough?
> 
> Benoît
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
> 

-- 
Loïc Hoguin
https://ninenines.eu



More information about the erlang-questions mailing list