pub struct Garbage { /* private fields */ }Expand description
A garbage queue.
This is where a concurrent data structure can store removed objects for deferred destruction.
Stored garbage objects are first kept in the garbage buffer. When the buffer becomes full, it’s
objects are flushed into the garbage queue. Flushing can be manually triggered by calling
flush.
Some garbage in the queue can be manually collected by calling collect.
Implementations§
Source§impl Garbage
impl Garbage
Sourcepub unsafe fn defer_free<T>(
&self,
object: *const T,
count: usize,
scope: &Scope,
)
pub unsafe fn defer_free<T>( &self, object: *const T, count: usize, scope: &Scope, )
Adds an object that will later be freed.
The specified object is an array allocated at address object and consists of count
elements of type T.
This method inserts the object into the garbage buffer. When the buffers becomes full, it’s objects are flushed into the garbage queue.
Sourcepub unsafe fn defer_drop<T>(
&self,
object: *const T,
count: usize,
scope: &Scope,
)
pub unsafe fn defer_drop<T>( &self, object: *const T, count: usize, scope: &Scope, )
Adds an object that will later be dropped and freed.
The specified object is an array allocated at address object and consists of count
elements of type T.
This method inserts the object into the garbage buffer. When the buffers becomes full, it’s objects are flushed into the garbage queue.
Note: The object must be Send + 'self.
Sourcepub unsafe fn defer_destroy<T>(
&self,
destroy: unsafe fn(*mut T, usize),
object: *const T,
count: usize,
scope: &Scope,
)
pub unsafe fn defer_destroy<T>( &self, destroy: unsafe fn(*mut T, usize), object: *const T, count: usize, scope: &Scope, )
Adds an object that will later be destroyed using destroy.
The specified object is an array allocated at address object and consists of count
elements of type T.
This method inserts the object into the garbage buffer. When the buffers becomes full, it’s objects are flushed into the garbage queue.
Note: The object must be Send + 'self.
Sourcepub fn flush(&self, scope: &Scope)
pub fn flush(&self, scope: &Scope)
Flushes the buffered garbage.
It is wise to flush the garbage just after passing a very large object to one of the
defer_* methods, so that it isn’t sitting in the buffer for a long time.
Sourcepub fn collect(&self, scope: &Scope)
pub fn collect(&self, scope: &Scope)
Collects some garbage from the queue and destroys it.
Generally speaking, it’s not necessary to call this method because garbage production already triggers garbage destruction. However, if there are long periods without garbage production, it might be a good idea to call this method from time to time.
This method collects several buffers worth of garbage objects.
Trait Implementations§
impl Send for Garbage
impl Sync for Garbage
Auto Trait Implementations§
impl !Freeze for Garbage
impl !RefUnwindSafe for Garbage
impl Unpin for Garbage
impl !UnwindSafe for Garbage
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<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