Struct Scope

Source
pub struct Scope { /* private fields */ }
Expand description

A witness that the current thread is pinned.

A reference to Scope is proof that the current thread is pinned. Lots of methods that interact with Atomics can safely be called only while the thread is pinned so they often require a reference to Scope.

This data type is inherently bound to the thread that created it, therefore it does not implement Send nor Sync.

Implementations§

Source§

impl Scope

Source

pub unsafe fn defer_free<T>(&self, ptr: Ptr<'_, T>)

Stashes away an object that will later be freed.

This function inserts the object into a thread-local buffer. When the buffers becomes full, it’s objects are flushed into the globally shared Garbage instance.

If the object is unusually large, it is wise to follow up with a call to flush so that it doesn’t get stuck waiting in the buffer for a long time.

Source

pub unsafe fn defer_drop<T>(&self, ptr: Ptr<'_, T>)

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 fn flush(&self)

Flushes the buffered thread-local garbage.

It is wise to flush the garbage just after passing a very large object to defer_free, so that it isn’t sitting in the buffer for a long time.

Trait Implementations§

Source§

impl Debug for Scope

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Scope

§

impl !RefUnwindSafe for Scope

§

impl !Send for Scope

§

impl !Sync for Scope

§

impl Unpin for Scope

§

impl !UnwindSafe for Scope

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.