summaryrefslogtreecommitdiff
path: root/deps
diff options
context:
space:
mode:
authorGabriel Schulhof <gabriel.schulhof@intel.com>2019-09-05 18:38:19 -0700
committerGabriel Schulhof <gabriel.schulhof@intel.com>2019-10-13 00:07:43 -0700
commit53ca0b9ae145c430842bf78e553e3b6cbd2823aa (patch)
treee7eb7372e2bd4cc16deeaa7310417f024231ffd6 /deps
parentfce1a5198a89e8f62ea2d093e01971db46da9bf5 (diff)
downloadandroid-node-v8-53ca0b9ae145c430842bf78e553e3b6cbd2823aa.tar.gz
android-node-v8-53ca0b9ae145c430842bf78e553e3b6cbd2823aa.tar.bz2
android-node-v8-53ca0b9ae145c430842bf78e553e3b6cbd2823aa.zip
src: render N-API weak callbacks as cleanup hooks
Since worker threads are complete Node.js environments, including the ability to load native addons, and since those native addons can allocate resources to be freed when objects go out of scope, and since, upon worker thread exit, the engine does not invoke the weak callbacks responsible for freeing resources which still have references, this modification introduces tracking for weak references such that a list of outstanding weak references is maintained. This list is traversed during environment teardown. The callbacks for the remaining weak references are called. This change is also relevant for Node.js embedder scenarios, because in those cases the process also outlives the `node::Environment` and therefore weak callbacks should also be rendered as environment cleanup hooks to ensure proper cleanup after native addons. This changes introduces the means by which this can be accomplished. A benchmark is included which measures the time it takes to execute the weak reference callback for a given number of weak references. Re: https://github.com/tc39/proposal-weakrefs/issues/125#issuecomment-535832130 PR-URL: https://github.com/nodejs/node/pull/28428 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Diffstat (limited to 'deps')
0 files changed, 0 insertions, 0 deletions