mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-05-30 03:01:21 +00:00
Cleanup in spawning tasks (#1181)
This commit is contained in:
parent
e4d43030eb
commit
6d5aa86cef
@ -27,7 +27,7 @@ use crate::{
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
use fnv::FnvHashMap;
|
use fnv::FnvHashMap;
|
||||||
use futures::{prelude::*, stream, sync::mpsc};
|
use futures::{prelude::*, future::Executor, stream, sync::mpsc};
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
use std::{
|
use std::{
|
||||||
collections::hash_map::{Entry, OccupiedEntry},
|
collections::hash_map::{Entry, OccupiedEntry},
|
||||||
@ -35,7 +35,6 @@ use std::{
|
|||||||
fmt,
|
fmt,
|
||||||
mem
|
mem
|
||||||
};
|
};
|
||||||
use tokio_executor::Executor;
|
|
||||||
|
|
||||||
mod tests;
|
mod tests;
|
||||||
|
|
||||||
@ -361,11 +360,9 @@ impl<TInEvent, TOutEvent, TIntoHandler, TReachErr, THandlerErr, TUserData, TConn
|
|||||||
// We try to use the default executor, but fall back to polling the task manually if
|
// We try to use the default executor, but fall back to polling the task manually if
|
||||||
// no executor is available. This makes it possible to use the core in environments
|
// no executor is available. This makes it possible to use the core in environments
|
||||||
// outside of tokio.
|
// outside of tokio.
|
||||||
let mut executor = tokio_executor::DefaultExecutor::current();
|
let executor = tokio_executor::DefaultExecutor::current();
|
||||||
if executor.status().is_ok() {
|
if let Err(err) = executor.execute(to_spawn) {
|
||||||
executor.spawn(to_spawn).expect("failed to create a node task");
|
self.local_spawns.push(err.into_future());
|
||||||
} else {
|
|
||||||
self.local_spawns.push(to_spawn);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user