Re: Are NIF resources meant to be destroyed immediately on GC?
José Valim <[email protected]>
| Newsgroups | gmane.comp.lang.erlang.general |
|---|---|
| Message-ID | <CAGnRm4Jy1FS7Sxx42NvioiytaA1hhXkBT1XEbRKSCsHCdYuwOg@mail.gmail.com> |
Thanks everyone for the replies, I have a couple of things to try out now. On Tue, Nov 24, 2020 at 7:16 PM Sean Hinde <[email protected]> wrote: > > > On 23 Nov 2020, at 23:16, Sverker Eriksson <[email protected]> > wrote: > > Prior to OTP 22.0 resource destructors were called directly by the thread > that happened to decrease the reference counter down to zero. > From OTP 22.0 resource destructors are scheduled. This in order to ensure > a stable known execution context for the destructor callback. So it may not > have executed when erlang:garbage_collect returns, but will very soon > (unless you have a very overloaded system or a bug preventing ref counter > from reaching zero). > > /Sverker, Erlang/OTP > > > > This a really nice change. It opens the door to resource destructors being > safe for closing external resources like database handles that might take a > while. > > Super cool! > > Sean > >