process: Update to tokio-io, mio, and tokio-core changes

This commit is contained in:
Alex Crichton
2019-06-24 16:56:49 -07:00
committed by Ivan Petkov
parent 521dc94021
commit 1384b31d60
5 changed files with 37 additions and 18 deletions
+5 -4
View File
@@ -16,10 +16,11 @@ travis-ci = { repository = "alexcrichton/tokio-process" }
appveyor = { repository = "alexcrichton/tokio-process" } appveyor = { repository = "alexcrichton/tokio-process" }
[dependencies] [dependencies]
tokio-core = "0.1.2" futures = "0.1.11"
futures = "0.1.7"
mio = "0.6"
log = "0.3" log = "0.3"
mio = "0.6.5"
tokio-core = "0.1.6"
tokio-io = "0.1"
[dev-dependencies] [dev-dependencies]
env_logger = { version = "0.3", default-features = false } env_logger = { version = "0.3", default-features = false }
@@ -31,4 +32,4 @@ mio-named-pipes = "0.1"
[target.'cfg(unix)'.dependencies] [target.'cfg(unix)'.dependencies]
libc = "0.2" libc = "0.2"
tokio-signal = "0.1.2" tokio-signal = "0.1"
+15 -1
View File
@@ -86,6 +86,7 @@
#[macro_use] #[macro_use]
extern crate futures; extern crate futures;
extern crate tokio_core; extern crate tokio_core;
extern crate tokio_io;
extern crate mio; extern crate mio;
#[macro_use] #[macro_use]
extern crate log; extern crate log;
@@ -98,7 +99,8 @@ use std::process::{self, ExitStatus, Output, Stdio};
use futures::{Future, Poll, IntoFuture}; use futures::{Future, Poll, IntoFuture};
use futures::future::{Flatten, FutureResult, Either, ok}; use futures::future::{Flatten, FutureResult, Either, ok};
use tokio_core::reactor::Handle; use tokio_core::reactor::Handle;
use tokio_core::io::{IoFuture, read_to_end}; use tokio_io::io::{read_to_end};
use tokio_io::{AsyncWrite, AsyncRead, IoFuture};
#[path = "unix.rs"] #[path = "unix.rs"]
#[cfg(unix)] #[cfg(unix)]
@@ -423,18 +425,30 @@ impl Write for ChildStdin {
} }
} }
impl AsyncWrite for ChildStdin {
fn shutdown(&mut self) -> Poll<(), io::Error> {
self.inner.shutdown()
}
}
impl Read for ChildStdout { impl Read for ChildStdout {
fn read(&mut self, bytes: &mut [u8]) -> io::Result<usize> { fn read(&mut self, bytes: &mut [u8]) -> io::Result<usize> {
self.inner.read(bytes) self.inner.read(bytes)
} }
} }
impl AsyncRead for ChildStdout {
}
impl Read for ChildStderr { impl Read for ChildStderr {
fn read(&mut self, bytes: &mut [u8]) -> io::Result<usize> { fn read(&mut self, bytes: &mut [u8]) -> io::Result<usize> {
self.inner.read(bytes) self.inner.read(bytes)
} }
} }
impl AsyncRead for ChildStderr {
}
// deprecated from 0.1.0 // deprecated from 0.1.0
#[deprecated(note = "use std::process::Command instead")] #[deprecated(note = "use std::process::Command instead")]
+6 -5
View File
@@ -30,12 +30,13 @@ use std::process::{self, ExitStatus};
use futures::future::FlattenStream; use futures::future::FlattenStream;
use futures::{Future, Poll, Async, Stream}; use futures::{Future, Poll, Async, Stream};
use mio::unix::EventedFd; use mio::unix::{EventedFd, UnixReady};
use mio::{Evented, PollOpt, Ready, Token}; use mio::{PollOpt, Ready, Token};
use mio::event::Evented;
use mio; use mio;
use self::libc::c_int; use self::libc::c_int;
use self::tokio_signal::unix::Signal; use self::tokio_signal::unix::Signal;
use tokio_core::io::IoFuture; use tokio_io::IoFuture;
use tokio_core::reactor::{Handle, PollEvented}; use tokio_core::reactor::{Handle, PollEvented};
pub struct Child { pub struct Child {
@@ -155,7 +156,7 @@ impl<T> Evented for Fd<T> where T: AsRawFd {
-> io::Result<()> { -> io::Result<()> {
EventedFd(&self.0.as_raw_fd()).register(poll, EventedFd(&self.0.as_raw_fd()).register(poll,
token, token,
interest | Ready::hup(), interest | UnixReady::hup(),
opts) opts)
} }
@@ -167,7 +168,7 @@ impl<T> Evented for Fd<T> where T: AsRawFd {
-> io::Result<()> { -> io::Result<()> {
EventedFd(&self.0.as_raw_fd()).reregister(poll, EventedFd(&self.0.as_raw_fd()).reregister(poll,
token, token,
interest | Ready::hup(), interest | UnixReady::hup(),
opts) opts)
} }
+8 -6
View File
@@ -24,7 +24,9 @@ use std::os::windows::prelude::*;
use std::os::windows::process::ExitStatusExt; use std::os::windows::process::ExitStatusExt;
use std::process::{self, ExitStatus}; use std::process::{self, ExitStatus};
use futures::{Future, Poll, Async, Oneshot, Complete, oneshot, Fuse}; use futures::{Future, Poll, Async} ;
use futures::sync::oneshot;
use futures::future::Fuse;
use self::mio_named_pipes::NamedPipe; use self::mio_named_pipes::NamedPipe;
use tokio_core::reactor::{PollEvented, Handle}; use tokio_core::reactor::{PollEvented, Handle};
@@ -34,9 +36,9 @@ pub struct Child {
} }
struct Waiting { struct Waiting {
rx: Fuse<Oneshot<()>>, rx: Fuse<oneshot::Receiver<()>>,
wait_object: winapi::HANDLE, wait_object: winapi::HANDLE,
tx: *mut Option<Complete<()>>, tx: *mut Option<oneshot::Sender<()>>,
} }
unsafe impl Sync for Waiting {} unsafe impl Sync for Waiting {}
@@ -87,7 +89,7 @@ impl Child {
if let Some(e) = try!(try_wait(&self.child)) { if let Some(e) = try!(try_wait(&self.child)) {
return Ok(e.into()) return Ok(e.into())
} }
let (tx, rx) = oneshot(); let (tx, rx) = oneshot::channel();
let ptr = Box::into_raw(Box::new(Some(tx))); let ptr = Box::into_raw(Box::new(Some(tx)));
let mut wait_object = 0 as *mut _; let mut wait_object = 0 as *mut _;
let rc = unsafe { let rc = unsafe {
@@ -128,8 +130,8 @@ impl Drop for Waiting {
unsafe extern "system" fn callback(ptr: winapi::PVOID, unsafe extern "system" fn callback(ptr: winapi::PVOID,
_timer_fired: winapi::BOOLEAN) { _timer_fired: winapi::BOOLEAN) {
let mut complete = &mut *(ptr as *mut Option<Complete<()>>); let mut complete = &mut *(ptr as *mut Option<oneshot::Sender<()>>);
complete.take().unwrap().complete(()); drop(complete.take().unwrap().send(()));
} }
pub fn try_wait(child: &process::Child) -> io::Result<Option<ExitStatus>> { pub fn try_wait(child: &process::Child) -> io::Result<Option<ExitStatus>> {
+3 -2
View File
@@ -1,6 +1,7 @@
extern crate futures; extern crate futures;
#[macro_use] #[macro_use]
extern crate tokio_core; extern crate tokio_core;
extern crate tokio_io;
extern crate tokio_process; extern crate tokio_process;
#[macro_use] #[macro_use]
extern crate log; extern crate log;
@@ -9,9 +10,9 @@ extern crate env_logger;
use std::io; use std::io;
use std::process::{Stdio, ExitStatus, Command}; use std::process::{Stdio, ExitStatus, Command};
use futures::{Future, BoxFuture}; use futures::future::{BoxFuture, Future};
use futures::stream::{self, Stream}; use futures::stream::{self, Stream};
use tokio_core::io::{read_until, write_all, read_to_end}; use tokio_io::io::{read_until, write_all, read_to_end};
use tokio_core::reactor::Core; use tokio_core::reactor::Core;
use tokio_process::{CommandExt, Child}; use tokio_process::{CommandExt, Child};