pub trait ExecutorPerform<X>: Send + Sync {
// Required methods
fn spawn_in_context<'async_trait, F>(
future: F,
) -> Pin<Box<dyn Future<Output = Result<Arc<dyn Task<F::Output, Output = F::Output>>, SpawnError>> + Send + 'async_trait>>
where F: Future + Send + 'static + 'async_trait,
F::Output: Send + 'static;
fn spawn_from_executor<'life0, 'async_trait, E, F>(
executor: &'life0 E,
future: F,
) -> Pin<Box<dyn Future<Output = Result<Arc<dyn Task<F::Output, Output = F::Output>>, SpawnError>> + Send + 'async_trait>>
where E: Executor<X> + 'async_trait,
F: Future + Send + 'static + 'async_trait,
F::Output: Send + 'static,
'life0: 'async_trait;
fn block_from_executor<'life0, 'async_trait, E, F>(
executor: &'life0 E,
future: F,
) -> Pin<Box<dyn Future<Output = F::Output> + Send + 'async_trait>>
where E: Executor<X> + 'async_trait,
F: Future + Send + 'static + 'async_trait,
F::Output: Send + 'static,
'life0: 'async_trait;
fn spawn_in_context_sync<F>(
future: F,
) -> Result<Arc<dyn Task<F::Output, Output = F::Output>>, SpawnError>
where F: Future + Send + 'static,
F::Output: Send + 'static;
fn spawn_from_executor_sync<E, F>(
executor: &E,
future: F,
) -> Result<Arc<dyn Task<F::Output, Output = F::Output>>, SpawnError>
where E: Executor<X>,
F: Future + Send + 'static,
F::Output: Send + 'static;
fn block_from_executor_sync<E, F>(executor: &E, future: F) -> F::Output
where E: Executor<X>,
F: Future + Send + 'static,
F::Output: Send + 'static;
}Expand description
Trait for spawning and managing async tasks.
This trait provides methods for spawning tasks on an executor and blocking
on futures. It complements the Executor trait by focusing on task execution.
§Type Parameters
X- The executor handle type
§Examples
use product_os_async_executor::{ExecutorPerform, TokioExecutor};
#[tokio::main]
async fn main() {
let task = TokioExecutor::spawn_in_context(async {
println!("Hello from spawned task!");
42
}).await;
assert!(task.is_ok());
}Required Methods§
Sourcefn spawn_in_context<'async_trait, F>(
future: F,
) -> Pin<Box<dyn Future<Output = Result<Arc<dyn Task<F::Output, Output = F::Output>>, SpawnError>> + Send + 'async_trait>>
fn spawn_in_context<'async_trait, F>( future: F, ) -> Pin<Box<dyn Future<Output = Result<Arc<dyn Task<F::Output, Output = F::Output>>, SpawnError>> + Send + 'async_trait>>
Spawns a task in the current context asynchronously.
§Errors
Returns an error if the task cannot be spawned.
Sourcefn spawn_from_executor<'life0, 'async_trait, E, F>(
executor: &'life0 E,
future: F,
) -> Pin<Box<dyn Future<Output = Result<Arc<dyn Task<F::Output, Output = F::Output>>, SpawnError>> + Send + 'async_trait>>
fn spawn_from_executor<'life0, 'async_trait, E, F>( executor: &'life0 E, future: F, ) -> Pin<Box<dyn Future<Output = Result<Arc<dyn Task<F::Output, Output = F::Output>>, SpawnError>> + Send + 'async_trait>>
Spawns a task from an executor asynchronously.
§Errors
Returns an error if the task cannot be spawned.
Sourcefn block_from_executor<'life0, 'async_trait, E, F>(
executor: &'life0 E,
future: F,
) -> Pin<Box<dyn Future<Output = F::Output> + Send + 'async_trait>>
fn block_from_executor<'life0, 'async_trait, E, F>( executor: &'life0 E, future: F, ) -> Pin<Box<dyn Future<Output = F::Output> + Send + 'async_trait>>
Blocks on a future using the executor.
This method blocks the current thread until the future completes.
Sourcefn spawn_in_context_sync<F>(
future: F,
) -> Result<Arc<dyn Task<F::Output, Output = F::Output>>, SpawnError>
fn spawn_in_context_sync<F>( future: F, ) -> Result<Arc<dyn Task<F::Output, Output = F::Output>>, SpawnError>
Spawns a task in the current context synchronously.
§Errors
Returns an error if the task cannot be spawned.
Sourcefn spawn_from_executor_sync<E, F>(
executor: &E,
future: F,
) -> Result<Arc<dyn Task<F::Output, Output = F::Output>>, SpawnError>
fn spawn_from_executor_sync<E, F>( executor: &E, future: F, ) -> Result<Arc<dyn Task<F::Output, Output = F::Output>>, SpawnError>
Spawns a task from an executor synchronously.
§Errors
Returns an error if the task cannot be spawned.
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.