pub trait OnDriverDispatcher: OnDispatcher {
// Provided methods
fn spawn_local(
&self,
future: impl Future<Output = ()> + 'static,
) -> Result<JoinHandle<()>, Status>
where Self: 'static { ... }
fn compute_local<T>(
&self,
future: impl Future<Output = T> + 'static,
) -> Result<Task<T>, Status>
where T: Send + 'static,
Self: 'static { ... }
}Expand description
Makes available additional functionality available on driver dispatchers on top of what’s
available on OnDispatcher.
Provided Methods§
Sourcefn spawn_local(
&self,
future: impl Future<Output = ()> + 'static,
) -> Result<JoinHandle<()>, Status>where
Self: 'static,
fn spawn_local(
&self,
future: impl Future<Output = ()> + 'static,
) -> Result<JoinHandle<()>, Status>where
Self: 'static,
Spawn an asynchronous local task on this dispatcher. If this returns Ok then the task
has successfully been scheduled and will run or be cancelled and dropped when the dispatcher
shuts down. The returned future’s result will be Ok if the future completed
successfully, or an Err if the task did not complete for some reason (like the
dispatcher shut down).
Unlike OnDispatcher::spawn, this will accept a future that does not implement Send. If
called from a thread other than the one the dispatcher is running on or the dispatcher
is not guaranteed to always poll from the same thread, this will return
[Status::BAD_STATE].
Returns a JoinHandle that will detach the future when dropped.
Sourcefn compute_local<T>(
&self,
future: impl Future<Output = T> + 'static,
) -> Result<Task<T>, Status>where
T: Send + 'static,
Self: 'static,
fn compute_local<T>(
&self,
future: impl Future<Output = T> + 'static,
) -> Result<Task<T>, Status>where
T: Send + 'static,
Self: 'static,
Spawn a local asynchronous task that outputs type ‘T’ on this dispatcher. The returned future’s
result will be Ok if the task was started and completed successfully, or an Err if
the task couldn’t be started or failed to complete (for example because the dispatcher was
shutting down).
Returns a Task that will cancel the future when dropped.
Unlike OnDispatcher::compute, this will accept a future that does not implement Send. If
called from a thread other than the one the dispatcher is running on or the dispatcher
is not guaranteed to always poll from the same thread, this will return
[Status::BAD_STATE].
TODO(470088116): This may be the cause of some flakes, so care should be used with it in critical paths for now.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.