Skip to main content

CacheScope

Struct CacheScope 

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

A cache scope (C++ ArResolverScopedCache): a span, on one thread, over which work that asks for the same asset several times keeps what it opened, such as a package’s directory. The scope ends when the guard drops.

A scope begun while another is open on the thread shares that scope’s cache: an operation holds one without asking whether its caller does. A scope belongs to the thread that began it and the guard stays on that thread; handle gives the cache for a scope on another thread to share.

Implementations§

Source§

impl CacheScope

Source

pub fn begin() -> Self

Begins a scope on the calling thread. It shares the cache of the innermost scope open on the thread, and starts an empty one when there is none.

Source

pub fn begin_shared(handle: &CacheHandle) -> Self

Begins a scope on the calling thread that shares handle’s cache, the cache of a scope open on another thread.

TODO(rayon): nothing shares a cache across threads yet. A parallel load would begin each worker’s scope with the handle of the scope its caller holds.

Source

pub fn handle(&self) -> CacheHandle

The scope’s cache.

Source

pub fn current() -> Option<CacheHandle>

The cache of the innermost scope open on the calling thread.

Trait Implementations§

Source§

impl Drop for CacheScope

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.