weakref

Weak References

Functions

FunctionDescription
weakref_newCreate new weak reference to target pointer.
weakref_derefDereference: get target pointer. Returns 0 if released.
weakref_aliveCheck if reference is still alive.
weakref_releaseRelease the weak reference (mark target as gone).
weakref_idGet unique reference ID.
weakref_registry_newRegistry: tracks a collection of weak references. Layout: [0]=count, [1]=capa…
weakref_registerRegister a weak reference in the registry.
weakref_sweepSweep: count dead references and compact the registry. Returns number of dead…

Details

weakref_new

fn weakref_new(target: i64) -> &i64

Create new weak reference to target pointer.

weakref_deref

fn weakref_deref(wr: &i64) -> i64

Dereference: get target pointer. Returns 0 if released.

weakref_alive

fn weakref_alive(wr: &i64) -> i64

Check if reference is still alive.

weakref_release

fn weakref_release(wr: &i64)

Release the weak reference (mark target as gone).

weakref_id

fn weakref_id(wr: &i64) -> i64

Get unique reference ID.

weakref_registry_new

fn weakref_registry_new() -> &i64

Registry: tracks a collection of weak references. Layout: [0]=count, [1]=capacity, [2]=refs_ptr (&i64 array of WeakRef pointers)

weakref_register

fn weakref_register(reg: &i64, wr: &i64)

Register a weak reference in the registry.

weakref_sweep

fn weakref_sweep(reg: &i64) -> i64

Sweep: count dead references and compact the registry. Returns number of dead references removed.