pub struct AllocationGuard<'token> { /* private fields */ }
Expand description
Guard that updates the current thread to track allocations for the associated allocation group.
§Drop behavior
This guard has a Drop
implementation that resets the active allocation group back to the last previously active
allocation group. Calling exit
is generally preferred for being explicit about when the allocation group
begins and ends, though.
§Moving across threads
AllocationGuard
is specifically marked as !Send
as the active allocation group is tracked at a per-thread
level. If you acquire an AllocationGuard
and need to resume computation on another thread, such as across an
await point or when simply sending objects to another thread, you must first exit
the guard and move the
resulting AllocationGroupToken
. Once on the new thread, you can then reacquire the guard.
Implementations§
Source§impl<'token> AllocationGuard<'token>
impl<'token> AllocationGuard<'token>
Trait Implementations§
Auto Trait Implementations§
impl<'token> Freeze for AllocationGuard<'token>
impl<'token> RefUnwindSafe for AllocationGuard<'token>
impl<'token> !Send for AllocationGuard<'token>
impl<'token> Sync for AllocationGuard<'token>
impl<'token> Unpin for AllocationGuard<'token>
impl<'token> !UnwindSafe for AllocationGuard<'token>
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