Skip to content

Commit

Permalink
Add handle argument back to NamedPipe creation methods.
Browse files Browse the repository at this point in the history
Needed by `PollEvented2` to ensure a single consistent thread for use
by multiple pipe connections.
  • Loading branch information
c0gent committed Aug 29, 2018
1 parent a607e28 commit 49ec1ba
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,27 @@ 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 {
io: PollEvented2<mio_named_pipes::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)?,
})
}

Expand Down

0 comments on commit 49ec1ba

Please sign in to comment.