pub struct GarbageCollector<T> { /* private fields */ }Expand description
A request-aware garbage collector for built-in Pool types.
Successful acceleration-structure, buffer, and image requests are recorded until
GarbageCollector::collect_resources is called. Collection retains only cached resources that
the wrapped pool could use to satisfy those requests, then begins a new observation interval.
Calling collect_resources without making any requests clears all managed resources.
Checked-out resources remain valid during collection. Resources returning to a retained bucket are evaluated by the next collection, while resources returning to a removed bucket are dropped. Command buffers, descriptor pools, and render passes are forwarded without being collected.
§Examples
let mut pool = GarbageCollector::new(LazyPool::new(&device));
let buffer = pool.resource(BufferInfo::device_mem(
1024,
vk::BufferUsageFlags::STORAGE_BUFFER,
))?;
drop(buffer);
// Retain cached resources supporting requests made since the previous collection.
pool.collect_resources();Implementations§
Source§impl<T> GarbageCollector<T>
impl<T> GarbageCollector<T>
Source§impl<T> GarbageCollector<T>where
T: CollectResources,
impl<T> GarbageCollector<T>where
T: CollectResources,
Sourcepub fn collect_resources(&mut self)
pub fn collect_resources(&mut self)
Collects cached resources and begins a new request observation interval.
Only acceleration structures, buffers, and images supporting successful requests made since the previous call are retained. If there were no such requests, all managed resources are removed.