MCPcopy Create free account
hub / github.com/GNOME/gjs / update_heap_wrapper_weak_pointers

Method update_heap_wrapper_weak_pointers

gi/object.cpp:2450–2466  ·  view source on GitHub ↗

* ObjectInstance::update_heap_wrapper_weak_pointers: * * Private callback, called after the JS engine finishes garbage collection, and * notifies when weak pointers need to be either moved or swept. */

Source from the content-addressed store, hash-verified

2448 * notifies when weak pointers need to be either moved or swept.
2449 */
2450void ObjectInstance::update_heap_wrapper_weak_pointers(JSTracer* trc,
2451 JS::Compartment*,
2452 void*) {
2453 gjs_debug_lifecycle(GJS_DEBUG_GOBJECT, "Weak pointer update callback, "
2454 "%zu wrapped GObject(s) to examine",
2455 ObjectInstance::num_wrapped_gobjects());
2456
2457 // Take a lock on the queue till we're done with it, so that we don't
2458 // risk that another thread will queue something else while sweeping
2459 auto locked_queue = ToggleQueue::get_default();
2460
2461 ObjectInstance::remove_wrapped_gobjects_if(
2462 [&trc](ObjectInstance* instance) -> bool {
2463 return instance->weak_pointer_was_finalized(trc);
2464 },
2465 std::mem_fn(&ObjectInstance::disassociate_js_gobject));
2466}
2467
2468bool ObjectInstance::weak_pointer_was_finalized(JSTracer* trc) {
2469 if (has_wrapper() && !wrapper_is_rooted()) {

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected