make ctx.spawn blocking (#3337)

* make spawn sync

* improve error type
This commit is contained in:
Andronik Ordian
2021-06-22 03:43:40 +02:00
committed by GitHub
parent 9fa5d28e0b
commit ffc6f7c731
16 changed files with 27 additions and 80 deletions
+4 -4
View File
@@ -197,8 +197,8 @@ pub enum SubsystemError {
#[error(transparent)]
QueueError(#[from] mpsc::SendError),
#[error(transparent)]
TaskSpawn(#[from] futures::task::SpawnError),
#[error("Failed to spawn a task: {0}")]
TaskSpawn(&'static str),
#[error(transparent)]
Infallible(#[from] std::convert::Infallible),
@@ -293,10 +293,10 @@ pub trait SubsystemContext: Send + Sized + 'static {
async fn recv(&mut self) -> SubsystemResult<FromOverseer<Self::Message>>;
/// Spawn a child task on the executor.
async fn spawn(&mut self, name: &'static str, s: Pin<Box<dyn Future<Output = ()> + Send>>) -> SubsystemResult<()>;
fn spawn(&mut self, name: &'static str, s: Pin<Box<dyn Future<Output = ()> + Send>>) -> SubsystemResult<()>;
/// Spawn a blocking child task on the executor's dedicated thread pool.
async fn spawn_blocking(
fn spawn_blocking(
&mut self,
name: &'static str,
s: Pin<Box<dyn Future<Output = ()> + Send>>,