pub trait AsyncLocal<T>
where T: AsContext,
{ // Required methods fn with_blocking<F, R>(&'static self, f: F) -> JoinHandle<R> where F: for<'id> FnOnce(LocalRef<'id, T::Target>) -> R + Send + 'static, R: Send + 'static; fn local_ref<'id>( &'static self, guard: Guard<'id> ) -> LocalRef<'id, T::Target>; }
Expand description

LocalKey extension for creating thread-safe pointers to thread-local Context

Required Methods§

source

fn with_blocking<F, R>(&'static self, f: F) -> JoinHandle<R>
where F: for<'id> FnOnce(LocalRef<'id, T::Target>) -> R + Send + 'static, R: Send + 'static,

Available on crate features tokio-runtime or barrier-protected-runtime only.

A wrapper around tokio::task::spawn_blocking that safely constrains the lifetime of LocalRef

source

fn local_ref<'id>(&'static self, guard: Guard<'id>) -> LocalRef<'id, T::Target>

Create a pointer to a thread local Context using a trusted lifetime carrier.

§Usage

Use generativity::make_guard to generate a unique invariant lifetime brand

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<T> AsyncLocal<T> for LocalKey<T>
where T: AsContext,

source§

fn with_blocking<F, R>(&'static self, f: F) -> JoinHandle<R>
where F: for<'id> FnOnce(LocalRef<'id, T::Target>) -> R + Send + 'static, R: Send + 'static,

Available on crate features tokio-runtime or barrier-protected-runtime only.
source§

fn local_ref<'id>(&'static self, guard: Guard<'id>) -> LocalRef<'id, T::Target>

Implementors§