Skip to content

Commit 7f376fd

Browse files
authored
Merge pull request #51 from coolreader18/tokio1
Upgrade to tokio 1.0
2 parents 7a4ef73 + da3eaa0 commit 7f376fd

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ http = "0.2"
2222
failure = "0.1.3"
2323
futures-util = "0.3.5"
2424
log = "0.4.6"
25-
tokio = { version = "0.2.21", features = ["process", "time", "io-util", "stream", "rt-core", "rt-threaded"] }
25+
tokio = { version = "1.0", features = ["process", "time", "io-util", "rt", "rt-multi-thread"] }
26+
tokio-stream = { version = "0.1", features = ["io-util"] }
2627
serde = { version = "1.0", features = ["derive"] }
2728
serde_json = "1.0"
2829
scopeguard = "1.0.0"

src/cmd/mod.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ use tokio::{
2424
io::{AsyncBufReadExt, BufReader},
2525
process::Command as AsyncCommand,
2626
runtime::Runtime,
27-
stream::StreamExt,
2827
time,
2928
};
29+
use tokio_stream::{wrappers::LinesStream, StreamExt};
3030

3131
lazy_static::lazy_static! {
3232
// TODO: Migrate to asynchronous code and remove runtime
@@ -480,7 +480,6 @@ impl<'w, 'pl> Command<'w, 'pl> {
480480
}
481481

482482
let out = RUNTIME
483-
.handle()
484483
.block_on(log_command(
485484
cmd,
486485
self.process_lines,
@@ -574,13 +573,11 @@ async fn log_command(
574573
};
575574

576575
let mut child = cmd.stdout(Stdio::piped()).stderr(Stdio::piped()).spawn()?;
577-
let child_id = child.id();
576+
let child_id = child.id().unwrap();
578577

579-
let stdout = BufReader::new(child.stdout.take().unwrap())
580-
.lines()
578+
let stdout = LinesStream::new(BufReader::new(child.stdout.take().unwrap()).lines())
581579
.map(|line| (OutputKind::Stdout, line));
582-
let stderr = BufReader::new(child.stderr.take().unwrap())
583-
.lines()
580+
let stderr = LinesStream::new(BufReader::new(child.stderr.take().unwrap()).lines())
584581
.map(|line| (OutputKind::Stderr, line));
585582

586583
let start = Instant::now();
@@ -642,7 +639,7 @@ async fn log_command(
642639
},
643640
);
644641

645-
let child = time::timeout(timeout, child).map(move |result| {
642+
let child = time::timeout(timeout, child.wait()).map(move |result| {
646643
match result {
647644
// If the timeout elapses, kill the process
648645
Err(_timeout) => Err(match native::kill_process(child_id) {

src/toolchain.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ impl Toolchain {
399399
/// # Ok(())
400400
/// # }
401401
/// ```
402-
pub fn cargo<'a>(&'a self) -> impl Runnable + 'a {
402+
pub fn cargo(&self) -> impl Runnable + '_ {
403403
RustupProxy {
404404
toolchain: self,
405405
name: "cargo",
@@ -423,7 +423,7 @@ impl Toolchain {
423423
/// # Ok(())
424424
/// # }
425425
/// ```
426-
pub fn rustc<'a>(&'a self) -> impl Runnable + 'a {
426+
pub fn rustc(&self) -> impl Runnable + '_ {
427427
RustupProxy {
428428
toolchain: self,
429429
name: "rustc",

0 commit comments

Comments
 (0)