pub struct MemoryConsumer { /* private fields */ }
Expand description
A memory consumer is a named allocation traced by a particular
MemoryReservation
in a MemoryPool
. All allocations are registered to
a particular MemoryConsumer
;
Each MemoryConsumer
is identifiable by a process-unique id, and is therefor not cloneable,
If you want a clone of a MemoryConsumer
, you should look into MemoryConsumer::clone_with_new_id
,
but note that this MemoryConsumer
may be treated as a separate entity based on the used pool,
and is only guaranteed to share the name and inner properties.
For help with allocation accounting, see the proxy
module.
Implementations§
Source§impl MemoryConsumer
impl MemoryConsumer
Sourcepub fn new(name: impl Into<String>) -> MemoryConsumer
pub fn new(name: impl Into<String>) -> MemoryConsumer
Create a new empty MemoryConsumer
that can be grown using MemoryReservation
Sourcepub fn clone_with_new_id(&self) -> MemoryConsumer
pub fn clone_with_new_id(&self) -> MemoryConsumer
Returns a clone of this MemoryConsumer
with a new unique id,
which can be registered with a MemoryPool
,
This new consumer is separate from the original.
Sourcepub fn id(&self) -> usize
pub fn id(&self) -> usize
Return the unique id of this MemoryConsumer
Sourcepub fn with_can_spill(self, can_spill: bool) -> MemoryConsumer
pub fn with_can_spill(self, can_spill: bool) -> MemoryConsumer
Set whether this allocation can be spilled to disk
Sourcepub fn register(self, pool: &Arc<dyn MemoryPool>) -> MemoryReservation
pub fn register(self, pool: &Arc<dyn MemoryPool>) -> MemoryReservation
Registers this MemoryConsumer
with the provided MemoryPool
returning
a MemoryReservation
that can be used to grow or shrink the memory reservation
Trait Implementations§
Source§impl Debug for MemoryConsumer
impl Debug for MemoryConsumer
Source§impl Hash for MemoryConsumer
impl Hash for MemoryConsumer
Source§impl PartialEq for MemoryConsumer
impl PartialEq for MemoryConsumer
impl Eq for MemoryConsumer
Auto Trait Implementations§
impl Freeze for MemoryConsumer
impl RefUnwindSafe for MemoryConsumer
impl Send for MemoryConsumer
impl Sync for MemoryConsumer
impl Unpin for MemoryConsumer
impl UnwindSafe for MemoryConsumer
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
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more