Struct async_local::LocalRef
source · pub struct LocalRef<T: Sync + 'static>(_);
Expand description
A thread-safe pointer to a thread local Context
Implementations§
source§impl<T> LocalRef<T>where
T: Sync + 'static,
impl<T> LocalRef<T>where
T: Sync + 'static,
sourcepub unsafe fn guarded_ref<'a>(&self) -> RefGuard<'a, T>
pub unsafe fn guarded_ref<'a>(&self) -> RefGuard<'a, T>
sourcepub fn with_blocking<F, R>(self, f: F) -> JoinHandle<R>where
F: for<'a> FnOnce(&'a LocalRef<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<'a> FnOnce(&'a LocalRef<T>) -> R + Send + 'static,
R: Send + 'static,
tokio-runtime
or async-std-runtime
only.A wrapper around spawn_blocking that protects LocalRef
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<T: Ord + Sync + 'static> Ord for LocalRef<T>
impl<T: Ord + Sync + 'static> Ord for LocalRef<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<T: PartialEq + Sync + 'static> PartialEq<LocalRef<T>> for LocalRef<T>
impl<T: PartialEq + Sync + 'static> PartialEq<LocalRef<T>> for LocalRef<T>
source§impl<T: PartialOrd + Sync + 'static> PartialOrd<LocalRef<T>> for LocalRef<T>
impl<T: PartialOrd + Sync + 'static> PartialOrd<LocalRef<T>> for LocalRef<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