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 Atomic
s 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
impl Scope
Sourcepub unsafe fn defer_free<T>(&self, ptr: Ptr<'_, T>)
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.
Sourcepub unsafe fn defer_drop<T>(&self, ptr: Ptr<'_, T>)
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
.
Sourcepub fn flush(&self)
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§
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> 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