Add handle argument back to `NamedPipe` creation methods.

Needed by `PollEvented2` to ensure a single consistent thread for use
by multiple pipe connections.
This commit is contained in:
Nick 2018-08-28 12:28:11 -07:00 committed by c0gent
parent a607e28346
commit 49ec1ba8bb
No known key found for this signature in database
GPG Key ID: 9CC25E71A743E892
1 changed files with 7 additions and 7 deletions

View File

@ -14,7 +14,7 @@ use std::os::windows::io::*;
use futures::{Async, Poll};
use bytes::{BufMut, Buf};
use mio::Ready;
use tokio::reactor::{PollEvented2};
use tokio::reactor::{Handle, PollEvented2};
use tokio::io::{AsyncRead, AsyncWrite};
pub struct NamedPipe {
@ -22,19 +22,19 @@ pub struct NamedPipe {
}
impl NamedPipe {
pub fn new<P: AsRef<OsStr>>(p: P) -> std::io::Result<NamedPipe> {
NamedPipe::_new(p.as_ref())
pub fn new<P: AsRef<OsStr>>(p: P, handle: &Handle) -> std::io::Result<NamedPipe> {
NamedPipe::_new(p.as_ref(), handle)
}
fn _new(p: &OsStr) -> std::io::Result<NamedPipe> {
fn _new(p: &OsStr, handle: &Handle) -> std::io::Result<NamedPipe> {
let inner = try!(mio_named_pipes::NamedPipe::new(p));
NamedPipe::from_pipe(inner)
NamedPipe::from_pipe(inner, handle)
}
pub fn from_pipe(pipe: mio_named_pipes::NamedPipe)
pub fn from_pipe(pipe: mio_named_pipes::NamedPipe, handle: &Handle)
-> std::io::Result<NamedPipe> {
Ok(NamedPipe {
io: PollEvented2::new(pipe),
io: PollEvented2::new_with_handle(pipe, handle)?,
})
}