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: delete callback bundle via reference #29479

Commits on Sep 6, 2019

  1. n-api: delete callback bundle via reference

    We should strive to use weak persistent references consistently
    throughout the code, since using `v8::Persistent` directly results
    in having to change many sites in the code when the way we use it
    changes.
    
    N-API uses `v8impl::Reference` internally when maintaining a weak
    persistent reference is necessary. So far, `v8impl::CallbackBundle` was
    using `v8::Persistent` directly in order to weakly reference the JS
    function backed by a N-API callback.
    
    The change introduced here reduces `v8impl::CallbackBundle` to a simple
    structure and uses a `v8impl::Reference` to weakly reference the N-API
    callback with which it is associated. The structure is freed by the
    `napi_finalize` callback of the `v8impl::Reference`. This brings
    N-API use of `v8::Persistent` completely under the `v8impl::Reference`
    umbrella, rendering our use of weak references consistent.
    Gabriel Schulhof committed Sep 6, 2019
    Configuration menu
    Copy the full SHA
    24aeefd View commit details
    Browse the repository at this point in the history