pub trait TaskExecutor:
Send
+ Sync
+ 'static {
type Guard<'a>
where Self: 'a;
// Required methods
fn block_on<T>(&self, task: T) -> T::Output
where T: Future + Send + 'static,
T::Output: Send + 'static;
fn spawn<F>(&self, task: F)
where F: Future<Output = ()> + Send + 'static;
fn spawn_blocking<T, R>(&self, task: T) -> BoxFuture<'_, DeltaResult<R>>
where T: FnOnce() -> R + Send + 'static,
R: Send + 'static;
fn enter(&self) -> Self::Guard<'_>;
}Expand description
An executor that can be used to run async tasks. This is used by IO functions
within the DefaultEngine.
This must be capable of running within an async context and running futures on another thread. This could be a multi-threaded runtime, like Tokio’s or could be a single-threaded runtime on a background thread.
Required Associated Types§
Required Methods§
Sourcefn block_on<T>(&self, task: T) -> T::Output
fn block_on<T>(&self, task: T) -> T::Output
Block on the given future, returning its output.
This should NOT panic if called within an async context. Thus it can’t
be implemented by tokio::runtime::Runtime::block_on.
fn spawn_blocking<T, R>(&self, task: T) -> BoxFuture<'_, DeltaResult<R>>
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".