Introduce tokio_old feature
This feature allows users to rely on the `0.2` version of `tokio` while the async ecosystem upgrades to the latest version.
This commit is contained in:
parent
a4ad1b297e
commit
782dd2f522
10 changed files with 67 additions and 9 deletions
21
futures/src/executor/tokio_old.rs
Normal file
21
futures/src/executor/tokio_old.rs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
use crate::Executor;
|
||||
|
||||
use futures::Future;
|
||||
|
||||
/// An old `tokio` runtime.
|
||||
#[cfg_attr(docsrs, doc(cfg(feature = "tokio_old")))]
|
||||
pub type TokioOld = tokio_old::runtime::Runtime;
|
||||
|
||||
impl Executor for TokioOld {
|
||||
fn new() -> Result<Self, futures::io::Error> {
|
||||
tokio_old::runtime::Runtime::new()
|
||||
}
|
||||
|
||||
fn spawn(&self, future: impl Future<Output = ()> + Send + 'static) {
|
||||
let _ = tokio_old::runtime::Runtime::spawn(self, future);
|
||||
}
|
||||
|
||||
fn enter<R>(&self, f: impl FnOnce() -> R) -> R {
|
||||
tokio_old::runtime::Runtime::enter(self, f)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue