pub struct DedicatedExecutor { /* private fields */ }Expand description
A long-lived handle to one dedicated session: every future spawned on it runs on that session’s single thread, never on the background pool.
Use this when tasks rely on thread-local state being coherent across spawns, or when the per-thread setup cost of the work is high enough that it should be paid once. Creating the session costs a thread (on the web, a worker — expensive); each spawn afterwards is just a channel send.
Dropping the handle cancels the session: queued and future spawns resolve to cancelled tasks.
Implementations§
Source§impl DedicatedExecutor
impl DedicatedExecutor
Sourcepub fn new(executor: &BackgroundExecutor) -> DedicatedExecutor
pub fn new(executor: &BackgroundExecutor) -> DedicatedExecutor
Starts a dedicated session on executor and returns a handle that
spawns futures onto it. Under TestScheduler the session runs on the
deterministic test loop; no real thread is created.
Auto Trait Implementations§
impl !RefUnwindSafe for DedicatedExecutor
impl !UnwindSafe for DedicatedExecutor
impl Freeze for DedicatedExecutor
impl Send for DedicatedExecutor
impl Sync for DedicatedExecutor
impl Unpin for DedicatedExecutor
impl UnsafeUnpin for DedicatedExecutor
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
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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> ⓘ
Converts
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> ⓘ
Converts
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