mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-18 00:00:09 +02:00
process: Update to tokio-io, mio, and tokio-core changes
This commit is contained in:
+5
-4
@@ -16,10 +16,11 @@ travis-ci = { repository = "alexcrichton/tokio-process" }
|
||||
appveyor = { repository = "alexcrichton/tokio-process" }
|
||||
|
||||
[dependencies]
|
||||
tokio-core = "0.1.2"
|
||||
futures = "0.1.7"
|
||||
mio = "0.6"
|
||||
futures = "0.1.11"
|
||||
log = "0.3"
|
||||
mio = "0.6.5"
|
||||
tokio-core = "0.1.6"
|
||||
tokio-io = "0.1"
|
||||
|
||||
[dev-dependencies]
|
||||
env_logger = { version = "0.3", default-features = false }
|
||||
@@ -31,4 +32,4 @@ mio-named-pipes = "0.1"
|
||||
|
||||
[target.'cfg(unix)'.dependencies]
|
||||
libc = "0.2"
|
||||
tokio-signal = "0.1.2"
|
||||
tokio-signal = "0.1"
|
||||
|
||||
+15
-1
@@ -86,6 +86,7 @@
|
||||
#[macro_use]
|
||||
extern crate futures;
|
||||
extern crate tokio_core;
|
||||
extern crate tokio_io;
|
||||
extern crate mio;
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
@@ -98,7 +99,8 @@ use std::process::{self, ExitStatus, Output, Stdio};
|
||||
use futures::{Future, Poll, IntoFuture};
|
||||
use futures::future::{Flatten, FutureResult, Either, ok};
|
||||
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"]
|
||||
#[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 {
|
||||
fn read(&mut self, bytes: &mut [u8]) -> io::Result<usize> {
|
||||
self.inner.read(bytes)
|
||||
}
|
||||
}
|
||||
|
||||
impl AsyncRead for ChildStdout {
|
||||
}
|
||||
|
||||
impl Read for ChildStderr {
|
||||
fn read(&mut self, bytes: &mut [u8]) -> io::Result<usize> {
|
||||
self.inner.read(bytes)
|
||||
}
|
||||
}
|
||||
|
||||
impl AsyncRead for ChildStderr {
|
||||
}
|
||||
|
||||
// deprecated from 0.1.0
|
||||
|
||||
#[deprecated(note = "use std::process::Command instead")]
|
||||
|
||||
+6
-5
@@ -30,12 +30,13 @@ use std::process::{self, ExitStatus};
|
||||
|
||||
use futures::future::FlattenStream;
|
||||
use futures::{Future, Poll, Async, Stream};
|
||||
use mio::unix::EventedFd;
|
||||
use mio::{Evented, PollOpt, Ready, Token};
|
||||
use mio::unix::{EventedFd, UnixReady};
|
||||
use mio::{PollOpt, Ready, Token};
|
||||
use mio::event::Evented;
|
||||
use mio;
|
||||
use self::libc::c_int;
|
||||
use self::tokio_signal::unix::Signal;
|
||||
use tokio_core::io::IoFuture;
|
||||
use tokio_io::IoFuture;
|
||||
use tokio_core::reactor::{Handle, PollEvented};
|
||||
|
||||
pub struct Child {
|
||||
@@ -155,7 +156,7 @@ impl<T> Evented for Fd<T> where T: AsRawFd {
|
||||
-> io::Result<()> {
|
||||
EventedFd(&self.0.as_raw_fd()).register(poll,
|
||||
token,
|
||||
interest | Ready::hup(),
|
||||
interest | UnixReady::hup(),
|
||||
opts)
|
||||
}
|
||||
|
||||
@@ -167,7 +168,7 @@ impl<T> Evented for Fd<T> where T: AsRawFd {
|
||||
-> io::Result<()> {
|
||||
EventedFd(&self.0.as_raw_fd()).reregister(poll,
|
||||
token,
|
||||
interest | Ready::hup(),
|
||||
interest | UnixReady::hup(),
|
||||
opts)
|
||||
}
|
||||
|
||||
|
||||
+8
-6
@@ -24,7 +24,9 @@ use std::os::windows::prelude::*;
|
||||
use std::os::windows::process::ExitStatusExt;
|
||||
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 tokio_core::reactor::{PollEvented, Handle};
|
||||
|
||||
@@ -34,9 +36,9 @@ pub struct Child {
|
||||
}
|
||||
|
||||
struct Waiting {
|
||||
rx: Fuse<Oneshot<()>>,
|
||||
rx: Fuse<oneshot::Receiver<()>>,
|
||||
wait_object: winapi::HANDLE,
|
||||
tx: *mut Option<Complete<()>>,
|
||||
tx: *mut Option<oneshot::Sender<()>>,
|
||||
}
|
||||
|
||||
unsafe impl Sync for Waiting {}
|
||||
@@ -87,7 +89,7 @@ impl Child {
|
||||
if let Some(e) = try!(try_wait(&self.child)) {
|
||||
return Ok(e.into())
|
||||
}
|
||||
let (tx, rx) = oneshot();
|
||||
let (tx, rx) = oneshot::channel();
|
||||
let ptr = Box::into_raw(Box::new(Some(tx)));
|
||||
let mut wait_object = 0 as *mut _;
|
||||
let rc = unsafe {
|
||||
@@ -128,8 +130,8 @@ impl Drop for Waiting {
|
||||
|
||||
unsafe extern "system" fn callback(ptr: winapi::PVOID,
|
||||
_timer_fired: winapi::BOOLEAN) {
|
||||
let mut complete = &mut *(ptr as *mut Option<Complete<()>>);
|
||||
complete.take().unwrap().complete(());
|
||||
let mut complete = &mut *(ptr as *mut Option<oneshot::Sender<()>>);
|
||||
drop(complete.take().unwrap().send(()));
|
||||
}
|
||||
|
||||
pub fn try_wait(child: &process::Child) -> io::Result<Option<ExitStatus>> {
|
||||
|
||||
+3
-2
@@ -1,6 +1,7 @@
|
||||
extern crate futures;
|
||||
#[macro_use]
|
||||
extern crate tokio_core;
|
||||
extern crate tokio_io;
|
||||
extern crate tokio_process;
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
@@ -9,9 +10,9 @@ extern crate env_logger;
|
||||
use std::io;
|
||||
use std::process::{Stdio, ExitStatus, Command};
|
||||
|
||||
use futures::{Future, BoxFuture};
|
||||
use futures::future::{BoxFuture, Future};
|
||||
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_process::{CommandExt, Child};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user