mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-29 00:00:11 +02:00
process: Misc polish (#1400)
* Denied all warnings in tests, and denied rust_2018_idioms violations
* Bumped the crate version and set publish = false
* Pruned dependencies:
- Only pull in tokio-sync on windows where it is used
- Removed unused dev-dependencies
* Switch to Async{Read, Write} traits from tokio-io rather than
futures-io
* Use #[tokio::test] where possible
* Removed deprecated items
* Fix all doc examples
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
extern crate tokio;
|
||||
#![deny(warnings, rust_2018_idioms)]
|
||||
|
||||
use futures_util::future;
|
||||
use futures_util::future::FutureExt;
|
||||
@@ -8,8 +8,6 @@ use std::process::Command;
|
||||
use std::time::Duration;
|
||||
use tokio::timer::Timeout;
|
||||
|
||||
pub use self::tokio::runtime::current_thread::Runtime as CurrentThreadRuntime;
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn cmd(s: &str) -> Command {
|
||||
let mut me = env::current_exe().unwrap();
|
||||
@@ -29,14 +27,3 @@ pub fn with_timeout<F: Future>(future: F) -> impl Future<Output = F::Output> {
|
||||
future::ready(r.unwrap())
|
||||
})
|
||||
}
|
||||
|
||||
pub fn run_with_timeout<F>(future: F) -> F::Output
|
||||
where
|
||||
F: Future,
|
||||
{
|
||||
// NB: Timeout requires a timer registration which is provided by
|
||||
// tokio's `current_thread::Runtime`, but isn't available by just using
|
||||
// tokio's default CurrentThread executor which powers `current_thread::block_on_all`.
|
||||
let mut rt = CurrentThreadRuntime::new().expect("failed to get runtime");
|
||||
rt.block_on(with_timeout(future))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user