Struct wgpu_core::pool::ResourcePool
source · pub struct ResourcePool<K, V> {
inner: Mutex<HashMap<K, Arc<OnceCell<Weak<V>>>, BuildHasherDefault<FxHasher>>>,
}
Fields§
§inner: Mutex<HashMap<K, Arc<OnceCell<Weak<V>>>, BuildHasherDefault<FxHasher>>>
Implementations§
source§impl<K: Clone + Eq + Hash, V> ResourcePool<K, V>
impl<K: Clone + Eq + Hash, V> ResourcePool<K, V>
pub fn new() -> Self
sourcepub fn get_or_init<F, E>(&self, key: K, constructor: F) -> Result<Arc<V>, E>
pub fn get_or_init<F, E>(&self, key: K, constructor: F) -> Result<Arc<V>, E>
Get a resource from the pool with the given entry map, or create a new one if it doesn’t exist using the given constructor.
Behaves such that only one resource will be created for each unique entry map at any one time.
sourcepub fn remove(&self, key: &K)
pub fn remove(&self, key: &K)
Remove the given entry map from the pool.
Must only be called in the Drop impl of BindGroupLayout
.
Auto Trait Implementations§
impl<K, V> !Freeze for ResourcePool<K, V>
impl<K, V> !RefUnwindSafe for ResourcePool<K, V>
impl<K, V> Send for ResourcePool<K, V>
impl<K, V> Sync for ResourcePool<K, V>
impl<K, V> Unpin for ResourcePool<K, V>where
K: Unpin,
impl<K, V> UnwindSafe for ResourcePool<K, V>where
K: UnwindSafe,
V: RefUnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more