usecrate::{
resource::{Blas, Trackable},
track::metadata::ResourceMetadata,
}; use alloc::sync::Arc;
/// A tracker that holds tracks BLASes. /// /// This is mostly a safe shell around [`ResourceMetadata`] #[derive(Debug)] pub(crate) struct BlasTracker {
metadata: ResourceMetadata<Arc<Blas>>,
size: usize,
}
/// Inserts a single resource into the resource tracker. /// /// Returns a reference to the newly inserted resource. /// (This allows avoiding a clone/reference count increase in many cases.) pubfn insert_single(&mutself, resource: Arc<Blas>) -> &Arc<Blas> { let index = resource.tracker_index().as_usize(); self.allow_index(index);
unsafe { // # SAFETY: we just allowed this resource, which makes the metadata object larger if // it's not in bounds self.metadata.insert(index, resource)
}
}
/// Sets the size of all the vectors inside the tracker. /// /// Must be called with the highest possible Texture ID before /// all unsafe functions are called. pubfn set_size(&mutself, size: usize) { self.size = size; self.metadata.set_size(size)
}
/// Extend the vectors to let the given index be valid. fn allow_index(&mutself, index: usize) { if index >= self.size { self.set_size(index + 1);
}
}
/// Returns true if the tracker owns the given texture. pubfn contains(&self, blas: &Blas) -> bool { self.metadata.contains(blas.tracker_index().as_usize())
}
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.13 Sekunden
(vorverarbeitet am 2026-08-25)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.