pub struct GarbageCollector { /* private fields */ }
Expand description
Wraps basedrop::Collector
with a polling GC thread.
This drops reference counted variables on a dedicated thread to avoid deallocating from the audio thread.
Implementations§
source§impl GarbageCollector
impl GarbageCollector
sourcepub fn new(collect_interval: Duration) -> Self
pub fn new(collect_interval: Duration) -> Self
Create the collector and start the garbage collector thread
sourcepub fn stop(&mut self) -> Result<(), GarbageCollectorError>
pub fn stop(&mut self) -> Result<(), GarbageCollectorError>
Stop & join the collector thread.
sourcepub fn blocking_collect(&self) -> bool
pub fn blocking_collect(&self) -> bool
Force GC on the current thread & return whether it was successful. Tries to acquire a lock on the collector.
sourcepub fn blocking_alloc_count(&self) -> usize
pub fn blocking_alloc_count(&self) -> usize
Gets the number of live allocations associated with the Collector
.
Tries to acquire a lock on the collector.