aleph_bft_types/tasks.rs
1use futures::Future;
2use std::pin::Pin;
3
4/// A handle for waiting the task's completion.
5pub type TaskHandle = Pin<Box<dyn Future<Output = Result<(), ()>> + Send>>;
6
7/// An abstraction for an execution engine for Rust's asynchronous tasks.
8pub trait SpawnHandle: Clone + Send + 'static {
9 /// Run a new task.
10 fn spawn(&self, name: &'static str, task: impl Future<Output = ()> + Send + 'static);
11 /// Run a new task and returns a handle to it. If there is some error or panic during
12 /// execution of the task, the handle should return an error.
13 fn spawn_essential(
14 &self,
15 name: &'static str,
16 task: impl Future<Output = ()> + Send + 'static,
17 ) -> TaskHandle;
18}