mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 15:51:12 +00:00
Expose that BasicQueue expects blocking spawn (#5860)
* Expose that `BasicQueue` expects blocking spawn Up to now `BasicQueue` expected a closure that to spawn a `Future`. This was expected to be a closure that spawns a blocking future. However, this wasn't documented anywhere. This pr introduces a new trait `SpawnBlocking` that exposes this requirement to the outside. * Feedback
This commit is contained in:
@@ -15,10 +15,10 @@
|
||||
|
||||
use std::{panic, pin::Pin, result::Result, sync::Arc};
|
||||
use exit_future::Signal;
|
||||
use log::{debug};
|
||||
use log::debug;
|
||||
use futures::{
|
||||
Future, FutureExt,
|
||||
future::{select, Either},
|
||||
future::{select, Either, BoxFuture},
|
||||
compat::*,
|
||||
task::{Spawn, FutureObj, SpawnError},
|
||||
};
|
||||
@@ -62,7 +62,12 @@ impl SpawnTaskHandle {
|
||||
}
|
||||
|
||||
/// Helper function that implements the spawning logic. See `spawn` and `spawn_blocking`.
|
||||
fn spawn_inner(&self, name: &'static str, task: impl Future<Output = ()> + Send + 'static, task_type: TaskType) {
|
||||
fn spawn_inner(
|
||||
&self,
|
||||
name: &'static str,
|
||||
task: impl Future<Output = ()> + Send + 'static,
|
||||
task_type: TaskType,
|
||||
) {
|
||||
let on_exit = self.on_exit.clone();
|
||||
let metrics = self.metrics.clone();
|
||||
|
||||
@@ -119,6 +124,12 @@ impl Spawn for SpawnTaskHandle {
|
||||
}
|
||||
}
|
||||
|
||||
impl sp_core::traits::SpawnBlocking for SpawnTaskHandle {
|
||||
fn spawn_blocking(&self, name: &'static str, future: BoxFuture<'static, ()>) {
|
||||
self.spawn_blocking(name, future);
|
||||
}
|
||||
}
|
||||
|
||||
impl sc_client_api::CloneableSpawn for SpawnTaskHandle {
|
||||
fn clone(&self) -> Box<dyn CloneableSpawn> {
|
||||
Box::new(Clone::clone(self))
|
||||
|
||||
Reference in New Issue
Block a user