Trait oxischeme::heap::Trace
[-]
[+]
[src]
pub trait Trace { fn trace(&self) -> IterGcThing; }
The Trace
trait allows GC participants to inform the collector of their
references to other GC things.
For example, imagine we had a Trio
type that contained three cons cells:
struct Trio { first: ConsPtr, second: ConsPtr, third: ConsPtr, }
Trio
's implementation of Trace
must yield all of its cons pointers, or
else their referents could be reclaimed by the garbage collector, and the
Trio
would have dangling pointers, leading to undefined behavior and bad
things when it dereferences them in the future.
impl Trace for Trio { fn trace(&self) -> IterGcThing { let refs = vec!(GcThing::from_cons_ptr(self.first), GcThing::from_cons_ptr(self.second), GcThing::from_cons_ptr(self.third)); refs.into_iter() } }
Required Methods
fn trace(&self) -> IterGcThing
Return an iterable of all of the GC things referenced by this structure.