Skip to main content

GcHandle

Struct GcHandle 

Source
pub struct GcHandle<'a> { /* private fields */ }
Expand description

A short-lived handle returned by state.gc() for GC operations.

In Phases A–C all methods are no-ops. Phase D replaces with real GC.

Implementations§

Source§

impl<'a> GcHandle<'a>

Source

pub fn check_step(&self)

macros.tsv: luaC_checkGC → state.gc().check_step()

Phase D-2: drives implicit collection when the heap’s byte threshold is exceeded. Without this hook, loops that allocate without an explicit collectgarbage() call (e.g. closure.lua’s while x[1] do local a = A..A end GC-driven loop) never settle.

Source

pub fn full_collect(&self)

macros.tsv: luaC_fullgc → state.gc().full_collect()

Source

pub fn step(&self)

Phase-B stub for luaC_step(L).

Source

pub fn incremental_step(&self, work_units: isize) -> bool

Run one budgeted incremental step of the GC.

work_units is the number of GC work units the step is allowed to perform (one gray trace, one sweep visit, or one phase transition). Returns true if the step completed a cycle and the collector is now in the Pause state; false otherwise.

Mirrors collect_via_heap for the post-mark weak-table / finalizer-promotion logic, but only the atomic-phase transition will invoke the snapshot-walking hook — propagate and sweep steps reuse the snapshot but never execute it. The snapshot is rebuilt on every call; the cost is O(weak_tables_registry) per step.

Source

pub fn prune_weak_tables_mark_only(&self)

Run only the weak-table atomic cleanup used by a generational step.

C-Lua’s genstep performs young/full generational work and includes weak-table clearing at the atomic boundary. This heap does not model ages yet; this mark-only pass gives explicit generational steps the weak cleanup they need without sweeping objects from suspended threads.

Source

pub fn change_mode(&self, mode: GcKind)

Set the GC kind (incremental/generational).

itself is Rc-based, so the only observable effect is the mode flag returned by lua_gc(LUA_GCGEN) / lua_gc(LUA_GCINC) on the next call.

Source

pub fn fix_object<T: Trace + 'static>(&self, _o: &GcRef<T>)

Phase-B stub for luaC_fix(L, o) — pin an object so GC won’t collect it.

Source

pub fn free_all_objects(&self)

Free all collectable objects (called during state teardown).

PORT NOTE: In Phases A–C, Rc drop chains handle deallocation automatically.

Source

pub fn barrier(&self, _p: &dyn Any, _v: &LuaValue)

GC write barrier for a TValue.

macros.tsv: luaC_barrier → state.gc().barrier(p, v) — no-op in Phases A–C

Source

pub fn barrier_back(&self, _p: &dyn Any, _v: &LuaValue)

Backward write barrier.

macros.tsv: luaC_barrierback → state.gc().barrier_back(p, v) — no-op

Source

pub fn obj_barrier(&self, _p: &dyn Any, _o: &dyn Any)

Object write barrier.

macros.tsv: luaC_objbarrier → state.gc().obj_barrier(p, o) — no-op

Source

pub fn obj_barrier_back(&self, _p: &dyn Any, _o: &dyn Any)

Backward object write barrier.

Auto Trait Implementations§

§

impl<'a> Freeze for GcHandle<'a>

§

impl<'a> !RefUnwindSafe for GcHandle<'a>

§

impl<'a> !Send for GcHandle<'a>

§

impl<'a> !Sync for GcHandle<'a>

§

impl<'a> Unpin for GcHandle<'a>

§

impl<'a> UnsafeUnpin for GcHandle<'a>

§

impl<'a> !UnwindSafe for GcHandle<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.