Struct wgpu_core::identity::IdentityManager
source · pub struct IdentityManager {
free: Vec<u32>,
epochs: Vec<u32>,
}
Expand description
A simple structure to allocate Id
identifiers.
Calling alloc
returns a fresh, never-before-seen id. Calling free
marks an id as dead; it will never be returned again by alloc
.
Use IdentityManager::default
to construct new instances.
IdentityManager
returns Id
s whose index values are suitable for use as
indices into a Storage<T>
that holds those ids’ referents:
-
Every live id has a distinct index value. Each live id’s index selects a distinct element in the vector.
-
IdentityManager
prefers low index numbers. If you size your vector to accommodate the indices produced here, the vector’s length will reflect the highwater mark of actual occupancy. -
IdentityManager
reuses the index values of freed ids before returning ids with new index values. Freed vector entries get reused.
See the module-level documentation for an overview of how this fits together.
Fields§
§free: Vec<u32>
Available index values. If empty, then epochs.len()
is the next index
to allocate.
epochs: Vec<u32>
The next or currently-live epoch value associated with each Id
index.
If there is a live id with index i
, then epochs[i]
is its epoch; any
id with the same index but an older epoch is dead.
If index i
is currently unused, epochs[i]
is the epoch to use in its
next Id
.