Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

n-api: render finalizers as env cleanup hooks #28428

Closed

Commits on Oct 13, 2019

  1. 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: tc39/proposal-weakrefs#125 (comment)
    Gabriel Schulhof committed Oct 13, 2019
    Configuration menu
    Copy the full SHA
    4f39a84 View commit details
    Browse the repository at this point in the history