mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 02:21:14 +00:00
create parallel tasks extension (#5249)
This commit is contained in:
@@ -212,3 +212,21 @@ impl CallInWasmExt {
|
||||
Self(Box::new(inner))
|
||||
}
|
||||
}
|
||||
|
||||
/// Something that can spawn tasks and also can be cloned.
|
||||
pub trait CloneableSpawn: futures::task::Spawn + Send + Sync {
|
||||
/// Clone as heap-allocated handle.
|
||||
fn clone(&self) -> Box<dyn CloneableSpawn>;
|
||||
}
|
||||
|
||||
sp_externalities::decl_extension! {
|
||||
/// Task executor extension.
|
||||
pub struct TaskExecutorExt(Box<dyn CloneableSpawn>);
|
||||
}
|
||||
|
||||
impl TaskExecutorExt {
|
||||
/// New instance of task executor extension.
|
||||
pub fn new(spawn_handle: Box<dyn CloneableSpawn>) -> Self {
|
||||
Self(spawn_handle)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user