Struct Garbage

Source
pub struct Garbage { /* private fields */ }
👎Deprecated since 0.2.0: Use scope::defer_free and scope::defer_drop instead
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

Source

pub fn new() -> Self

Returns a new, empty garbage queue.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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§

Source§

impl Debug for Garbage

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for Garbage

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Send for Garbage

Source§

impl Sync for Garbage

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.