Struct async_local::RefGuard
source · pub struct RefGuard<'a, T: Sync + 'static> { /* private fields */ }
Expand description
A thread-safe pointer to a thread-local Context
constrained by a phantom lifetime
Implementations§
source§impl<'a, T> RefGuard<'a, T>where
T: Sync + 'static,
impl<'a, T> RefGuard<'a, T>where
T: Sync + 'static,
sourcepub fn with_blocking<F, R>(self, f: F) -> JoinHandle<R>where
F: for<'b> FnOnce(RefGuard<'b, T>) -> R + Send + 'static,
R: Send + 'static,
Available on crate features tokio-runtime
or async-std-runtime
only.
pub fn with_blocking<F, R>(self, f: F) -> JoinHandle<R>where
F: for<'b> FnOnce(RefGuard<'b, T>) -> R + Send + 'static,
R: Send + 'static,
tokio-runtime
or async-std-runtime
only.A wrapper around spawn_blocking that protects RefGuard
for the lifetime of the spawned thread
Use the tokio-runtime
feature flag for tokio::task::spawn_blocking
or async-std-runtime
for async_std::task::spawn_blocking
Trait Implementations§
source§impl<'a, T: Ord + Sync + 'static> Ord for RefGuard<'a, T>
impl<'a, T: Ord + Sync + 'static> Ord for RefGuard<'a, T>
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
source§impl<'a, T: PartialEq + Sync + 'static> PartialEq<RefGuard<'a, T>> for RefGuard<'a, T>
impl<'a, T: PartialEq + Sync + 'static> PartialEq<RefGuard<'a, T>> for RefGuard<'a, T>
source§impl<'a, T: PartialOrd + Sync + 'static> PartialOrd<RefGuard<'a, T>> for RefGuard<'a, T>
impl<'a, T: PartialOrd + Sync + 'static> PartialOrd<RefGuard<'a, T>> for RefGuard<'a, T>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read more