Move spawning tasks from thread pools to Service's TaskManager for block importing (#5647)

Co-Authored-By: Pierre Krieger <pierre.krieger1708@gmail.com>
This commit is contained in:
pscott
2020-04-29 18:46:39 +02:00
committed by GitHub
parent bb94695a4e
commit 0f401e4699
22 changed files with 124 additions and 107 deletions
+10 -1
View File
@@ -38,7 +38,7 @@ pub struct Configuration {
/// Node role.
pub role: Role,
/// How to spawn background tasks. Mandatory, otherwise creating a `Service` will error.
pub task_executor: Arc<dyn Fn(Pin<Box<dyn Future<Output = ()> + Send>>) + Send + Sync>,
pub task_executor: Arc<dyn Fn(Pin<Box<dyn Future<Output = ()> + Send>>, TaskType) + Send + Sync>,
/// Extrinsic pool configuration.
pub transaction_pool: TransactionPoolOptions,
/// Network configuration.
@@ -102,6 +102,15 @@ pub struct Configuration {
pub announce_block: bool,
}
/// Type for tasks spawned by the executor.
#[derive(PartialEq)]
pub enum TaskType {
/// Regular non-blocking futures. Polling the task is expected to be a lightweight operation.
Async,
/// The task might perform a lot of expensive CPU operations and/or call `thread::sleep`.
Blocking,
}
/// Configuration of the client keystore.
#[derive(Clone)]
pub enum KeystoreConfig {