pub struct LocalDomain { /* private fields */ }Expand description
A thread-affine executor driven explicitly by the thread that creates it.
The Rc marker deliberately makes this type !Send + !Sync. In particular,
a LocalExecutor runnable is never sent through the cross-thread inbox.
Implementations§
Source§impl LocalDomain
impl LocalDomain
Sourcepub fn spawner(&self) -> LocalSpawner
pub fn spawner(&self) -> LocalSpawner
Returns a cross-thread capability that accepts Send futures only.
Sourcepub fn spawn_local<F, T>(&self, future: F) -> Result<Task<T>, SpawnError>where
F: Future<Output = T> + 'static,
T: 'static,
pub fn spawn_local<F, T>(&self, future: F) -> Result<Task<T>, SpawnError>where
F: Future<Output = T> + 'static,
T: 'static,
Spawns a future that is allowed to borrow only this local thread’s affinity.
§Errors
Returns SpawnError::Closed after this domain begins shutting down.
§Panics
Panics if the internal lifecycle mutex was poisoned by an earlier panic.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns whether the domain currently has no accepted, queued, or runnable work.
Sourcepub fn try_tick(&self) -> bool
pub fn try_tick(&self) -> bool
Processes a pending remote command or one scheduled local runnable.
Sourcepub fn run_n(&self, max_steps: usize) -> usize
pub fn run_n(&self, max_steps: usize) -> usize
Performs at most max_steps non-blocking drive steps.
Returns the number of steps that made progress. A step has the same
scheduling semantics as Self::try_tick; it is not a completed-task
count. Passing zero does not poll work.
Sourcepub fn run_for(&self, budget: Duration) -> RunStats
pub fn run_for(&self, budget: Duration) -> RunStats
Drives ready work without blocking until the soft time budget expires.
The clock is checked before every drive step. Rust futures cannot be
preempted during a single poll, so one slow poll may make elapsed
exceed budget. A zero budget does not poll work.
Sourcepub async fn run<F: Future>(&self, future: F) -> F::Output
pub async fn run<F: Future>(&self, future: F) -> F::Output
Drives this domain until future completes.
Sourcepub async fn shutdown_graceful(self)
pub async fn shutdown_graceful(self)
Rejects new work and drives accepted tasks to completion.
Sourcepub async fn shutdown_until<D>(self, deadline: D) -> ShutdownOutcomewhere
D: Future,
pub async fn shutdown_until<D>(self, deadline: D) -> ShutdownOutcomewhere
D: Future,
Gracefully drains until deadline resolves, then cancels remaining work.
The deadline future is supplied by the host, so this executor does not require or drive a particular timer or I/O reactor.
Sourcepub fn shutdown_now(self)
pub fn shutdown_now(self)
Rejects new work and drops the executor’s remaining local tasks.