[v8.x-backport] src: add environment cleanup hooks
This adds pairs of methods to the Environment
class and to public APIs
which can add and remove cleanup handlers.
Unlike AtExit
, this API targets addon developers rather than
embedders, giving them (and Node\u2019s internals) the ability to register
per-Environment
cleanup work.
We may want to replace AtExit
with this API at some point.
Many thanks for Stephen Belanger for reviewing the original version of this commit in the Ayo.js project.
Refs: https://github.com/ayojs/ayo/pull/82 PR-URL: https://github.com/nodejs/node/pull/19377
Checklist
-
make -j4 test
(UNIX), orvcbuild test
(Windows) passes -
tests and/or benchmarks are included -
documentation is changed or added -
commit message follows commit guidelines