Skip to main content

run_pending_finalizers

Function run_pending_finalizers 

Source
pub fn run_pending_finalizers(state: &mut LuaState)
Expand description

Phase-B __gc driver.

Scans pending_finalizers for tables whose only strong ref is the list itself (Rc::strong_count == 1), runs their __gc metamethod in a protected call, then drops the list’s pin so the table can be freed. Iterates in reverse so the most-recently registered finalizers run first, matching C-Lua’s order (finobj is a LIFO stack).

PORT NOTE: This stands in for C-Lua’s GCSatomic finalizer-promotion step plus GCTM. The real GC walks the heap to decide which finobj entries are unreachable; in Phase B we use the Rc strong-count as the proxy. Replaced by lua_gc::run_pending_finalizers when Phase D’s incremental GC lands.