Commit 8474b82
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.
PR-URL: #29479
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Anna Henningsen <anna@addaleax.net>1 parent b1509e8 commit 8474b82
1 file changed
+6
-18
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
379 | 379 | | |
380 | 380 | | |
381 | 381 | | |
382 | | - | |
383 | | - | |
384 | | - | |
385 | | - | |
386 | | - | |
387 | | - | |
388 | | - | |
389 | 382 | | |
390 | 383 | | |
391 | 384 | | |
392 | 385 | | |
393 | | - | |
394 | | - | |
395 | | - | |
396 | | - | |
397 | | - | |
398 | | - | |
399 | | - | |
400 | | - | |
401 | | - | |
402 | | - | |
403 | 386 | | |
404 | 387 | | |
405 | 388 | | |
| |||
580 | 563 | | |
581 | 564 | | |
582 | 565 | | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
583 | 571 | | |
584 | 572 | | |
585 | 573 | | |
| |||
591 | 579 | | |
592 | 580 | | |
593 | 581 | | |
594 | | - | |
| 582 | + | |
595 | 583 | | |
596 | 584 | | |
597 | 585 | | |
| |||
0 commit comments