Skip to main content

GarbageCollector

Struct GarbageCollector 

Source
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>

Source

pub fn new(pool: T) -> Self

Creates a garbage collector wrapper over the given pool.

Source§

impl<T> GarbageCollector<T>
where T: CollectResources,

Source

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.

Trait Implementations§

Source§

impl<T> Deref for GarbageCollector<T>

Source§

type Target = T

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<T> DerefMut for GarbageCollector<T>

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

impl<T> Pool<AccelerationStructureInfo, AccelerationStructure> for GarbageCollector<T>

Source§

impl<T> Pool<BufferInfo, Buffer> for GarbageCollector<T>
where T: Pool<BufferInfo, Buffer>,

Source§

fn resource(&mut self, info: BufferInfo) -> Result<Lease<Buffer>, DriverError>

Request a resource.
Source§

impl<T> Pool<CommandBufferInfo, CommandBuffer> for GarbageCollector<T>

Source§

fn resource( &mut self, info: CommandBufferInfo, ) -> Result<Lease<CommandBuffer>, DriverError>

Request a resource.
Source§

impl<T> Pool<ImageInfo, Image> for GarbageCollector<T>
where T: Pool<ImageInfo, Image>,

Source§

fn resource(&mut self, info: ImageInfo) -> Result<Lease<Image>, DriverError>

Request a resource.

Auto Trait Implementations§

§

impl<T> Freeze for GarbageCollector<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for GarbageCollector<T>
where T: RefUnwindSafe,

§

impl<T> Send for GarbageCollector<T>
where T: Send,

§

impl<T> Sync for GarbageCollector<T>
where T: Sync,

§

impl<T> Unpin for GarbageCollector<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for GarbageCollector<T>
where T: UnsafeUnpin,

§

impl<T> UnwindSafe for GarbageCollector<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pool<AccelerationStructureInfoBuilder, AccelerationStructure> for T

Source§

impl<T> Pool<BufferInfoBuilder, Buffer> for T
where T: Pool<BufferInfo, Buffer>,

Source§

fn resource( &mut self, builder: BufferInfoBuilder, ) -> Result<Lease<Buffer>, DriverError>

Request a resource.
Source§

impl<T> Pool<ImageInfoBuilder, Image> for T
where T: Pool<ImageInfo, Image>,

Source§

fn resource( &mut self, builder: ImageInfoBuilder, ) -> Result<Lease<Image>, DriverError>

Request a resource.
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> SubmissionPool for T
where T: SubmissionPoolSealed,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.