Migrate the last typedefs to ~Trait in rtio
There are no longer any remnants of typedefs, and everything is now built on true trait objects.
This commit is contained in:
parent
59d45b8fe7
commit
4ce71eaca3
4 changed files with 14 additions and 19 deletions
|
|
@ -13,7 +13,7 @@ use result::{Ok, Err};
|
|||
use rt::io::net::ip::SocketAddr;
|
||||
use rt::io::{Reader, Writer, Listener, Acceptor};
|
||||
use rt::io::{io_error, read_error, EndOfFile};
|
||||
use rt::rtio::{IoFactory, RtioTcpListenerObject, with_local_io,
|
||||
use rt::rtio::{IoFactory, with_local_io,
|
||||
RtioSocket, RtioTcpListener, RtioTcpAcceptor, RtioTcpStream};
|
||||
|
||||
pub struct TcpStream {
|
||||
|
|
@ -89,7 +89,7 @@ impl Writer for TcpStream {
|
|||
}
|
||||
|
||||
pub struct TcpListener {
|
||||
priv obj: ~RtioTcpListenerObject
|
||||
priv obj: ~RtioTcpListener
|
||||
}
|
||||
|
||||
impl TcpListener {
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ use prelude::*;
|
|||
|
||||
use c_str::ToCStr;
|
||||
use rt::rtio::{IoFactory, RtioUnixListener, with_local_io};
|
||||
use rt::rtio::{RtioUnixAcceptor, RtioPipe, RtioUnixListenerObject};
|
||||
use rt::rtio::{RtioUnixAcceptor, RtioPipe};
|
||||
use rt::io::pipe::PipeStream;
|
||||
use rt::io::{io_error, Listener, Acceptor, Reader, Writer};
|
||||
|
||||
|
|
@ -82,7 +82,7 @@ impl Writer for UnixStream {
|
|||
}
|
||||
|
||||
pub struct UnixListener {
|
||||
priv obj: ~RtioUnixListenerObject,
|
||||
priv obj: ~RtioUnixListener,
|
||||
}
|
||||
|
||||
impl UnixListener {
|
||||
|
|
|
|||
|
|
@ -18,15 +18,10 @@ use ai = rt::io::net::addrinfo;
|
|||
use rt::io::IoError;
|
||||
use super::io::process::ProcessConfig;
|
||||
use super::io::net::ip::{IpAddr, SocketAddr};
|
||||
use rt::uv::uvio;
|
||||
use path::Path;
|
||||
use super::io::{SeekStyle};
|
||||
use super::io::{FileMode, FileAccess, FileStat};
|
||||
|
||||
// FIXME(#9893) cannot call by-value self method on a trait object
|
||||
pub type RtioTcpListenerObject = uvio::UvTcpListener;
|
||||
pub type RtioUnixListenerObject = uvio::UvUnixListener;
|
||||
|
||||
pub trait EventLoop {
|
||||
fn run(&mut self);
|
||||
fn callback(&mut self, ~fn());
|
||||
|
|
@ -82,7 +77,7 @@ pub fn with_local_io<T>(f: &fn(&mut IoFactory) -> Option<T>) -> Option<T> {
|
|||
|
||||
pub trait IoFactory {
|
||||
fn tcp_connect(&mut self, addr: SocketAddr) -> Result<~RtioTcpStream, IoError>;
|
||||
fn tcp_bind(&mut self, addr: SocketAddr) -> Result<~RtioTcpListenerObject, IoError>;
|
||||
fn tcp_bind(&mut self, addr: SocketAddr) -> Result<~RtioTcpListener, IoError>;
|
||||
fn udp_bind(&mut self, addr: SocketAddr) -> Result<~RtioUdpSocket, IoError>;
|
||||
fn get_host_addresses(&mut self, host: Option<&str>, servname: Option<&str>,
|
||||
hint: Option<ai::Hint>) -> Result<~[ai::Info], IoError>;
|
||||
|
|
@ -100,14 +95,14 @@ pub trait IoFactory {
|
|||
-> Result<(~RtioProcess, ~[Option<~RtioPipe>]), IoError>;
|
||||
|
||||
fn unix_bind(&mut self, path: &CString) ->
|
||||
Result<~RtioUnixListenerObject, IoError>;
|
||||
Result<~RtioUnixListener, IoError>;
|
||||
fn unix_connect(&mut self, path: &CString) -> Result<~RtioPipe, IoError>;
|
||||
fn tty_open(&mut self, fd: c_int, readable: bool, close_on_drop: bool)
|
||||
-> Result<~RtioTTY, IoError>;
|
||||
}
|
||||
|
||||
pub trait RtioTcpListener : RtioSocket {
|
||||
fn listen(self) -> Result<~RtioTcpAcceptor, IoError>;
|
||||
fn listen(~self) -> Result<~RtioTcpAcceptor, IoError>;
|
||||
}
|
||||
|
||||
pub trait RtioTcpAcceptor : RtioSocket {
|
||||
|
|
@ -173,7 +168,7 @@ pub trait RtioPipe {
|
|||
}
|
||||
|
||||
pub trait RtioUnixListener {
|
||||
fn listen(self) -> Result<~RtioUnixAcceptor, IoError>;
|
||||
fn listen(~self) -> Result<~RtioUnixAcceptor, IoError>;
|
||||
}
|
||||
|
||||
pub trait RtioUnixAcceptor {
|
||||
|
|
|
|||
|
|
@ -493,12 +493,12 @@ impl IoFactory for UvIoFactory {
|
|||
return result_cell.take();
|
||||
}
|
||||
|
||||
fn tcp_bind(&mut self, addr: SocketAddr) -> Result<~RtioTcpListenerObject, IoError> {
|
||||
fn tcp_bind(&mut self, addr: SocketAddr) -> Result<~RtioTcpListener, IoError> {
|
||||
let mut watcher = TcpWatcher::new(self.uv_loop());
|
||||
match watcher.bind(addr) {
|
||||
Ok(_) => {
|
||||
let home = get_handle_to_current_scheduler!();
|
||||
Ok(~UvTcpListener::new(watcher, home))
|
||||
Ok(~UvTcpListener::new(watcher, home) as ~RtioTcpListener)
|
||||
}
|
||||
Err(uverr) => {
|
||||
do task::unkillable { // FIXME(#8674)
|
||||
|
|
@ -804,13 +804,13 @@ impl IoFactory for UvIoFactory {
|
|||
}
|
||||
|
||||
fn unix_bind(&mut self, path: &CString) ->
|
||||
Result<~RtioUnixListenerObject, IoError> {
|
||||
Result<~RtioUnixListener, IoError> {
|
||||
let mut pipe = Pipe::new(self.uv_loop(), false);
|
||||
match pipe.bind(path) {
|
||||
Ok(()) => {
|
||||
let handle = get_handle_to_current_scheduler!();
|
||||
let pipe = UvUnboundPipe::new(pipe, handle);
|
||||
Ok(~UvUnixListener::new(pipe))
|
||||
Ok(~UvUnixListener::new(pipe) as ~RtioUnixListener)
|
||||
}
|
||||
Err(e) => {
|
||||
let scheduler: ~Scheduler = Local::take();
|
||||
|
|
@ -919,7 +919,7 @@ impl RtioSocket for UvTcpListener {
|
|||
}
|
||||
|
||||
impl RtioTcpListener for UvTcpListener {
|
||||
fn listen(self) -> Result<~RtioTcpAcceptor, IoError> {
|
||||
fn listen(~self) -> Result<~RtioTcpAcceptor, IoError> {
|
||||
do self.home_for_io_consume |self_| {
|
||||
let acceptor = ~UvTcpAcceptor::new(self_);
|
||||
let incoming = Cell::new(acceptor.incoming.clone());
|
||||
|
|
@ -1717,7 +1717,7 @@ impl UvUnixListener {
|
|||
}
|
||||
|
||||
impl RtioUnixListener for UvUnixListener {
|
||||
fn listen(self) -> Result<~RtioUnixAcceptor, IoError> {
|
||||
fn listen(~self) -> Result<~RtioUnixAcceptor, IoError> {
|
||||
do self.home_for_io_consume |self_| {
|
||||
let acceptor = ~UvUnixAcceptor::new(self_);
|
||||
let incoming = Cell::new(acceptor.incoming.clone());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue