pub trait GarbageCollection<'a>: Send + Sync {
// Required method
fn collect_increment(&mut self) -> GcProgress;
// Provided method
fn collect(&mut self) { ... }
}
Expand description
A garbage collection process.
Implementations define the collect_increment
method, and then consumers
can either use
-
GarbageCollection::collect
for synchronous code, or -
collect_async(Box<dyn GarbageCollection>)
for async code.
When using fuel and/or epochs, consumers can also use collect_increment
directly and choose to abandon further execution in this GC’s heap’s whole
store if the GC is taking too long to complete.
Required Methods§
Sourcefn collect_increment(&mut self) -> GcProgress
fn collect_increment(&mut self) -> GcProgress
Perform an incremental slice of this garbage collection process.
Upon completion of the slice, a GcProgress
is returned which informs
the caller whether to continue driving this GC process forward and
executing more slices (GcProgress::Continue
) or whether the GC process
has finished (GcProgress::Complete
).
The mutator does not run in between increments. This method exists solely to allow cooperative yielding