diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2013-08-15 14:18:13 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2013-08-27 20:46:43 -0700 |
| commit | b89e1c000e133fb5db3ea5afd0948db6dc088977 (patch) | |
| tree | 6bd105ae723233519d985e61bdef09f4b0e13603 /src/libstd/rt/rtio.rs | |
| parent | ed204257a0c6abc8386879bb631471ec17d8a96a (diff) | |
| download | rust-b89e1c000e133fb5db3ea5afd0948db6dc088977.tar.gz rust-b89e1c000e133fb5db3ea5afd0948db6dc088977.zip | |
Implement process bindings to libuv
Closes #6436
Diffstat (limited to 'src/libstd/rt/rtio.rs')
| -rw-r--r-- | src/libstd/rt/rtio.rs | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/src/libstd/rt/rtio.rs b/src/libstd/rt/rtio.rs index 1788b7a04e3..1a7ef6ea309 100644 --- a/src/libstd/rt/rtio.rs +++ b/src/libstd/rt/rtio.rs @@ -8,12 +8,14 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use libc; use option::*; use result::*; use libc::c_int; use rt::io::IoError; use super::io::net::ip::{IpAddr, SocketAddr}; +use rt::uv; use rt::uv::uvio; use path::Path; use super::io::support::PathLike; @@ -30,6 +32,9 @@ pub type RtioTcpListenerObject = uvio::UvTcpListener; pub type RtioUdpSocketObject = uvio::UvUdpSocket; pub type RtioTimerObject = uvio::UvTimer; pub type PausibleIdleCallback = uvio::UvPausibleIdleCallback; +pub type RtioPipeObject = uvio::UvPipeStream; +pub type RtioProcessObject = uvio::UvProcess; +pub type RtioProcessConfig<'self> = uv::process::Config<'self>; pub trait EventLoop { fn run(&mut self); @@ -72,6 +77,13 @@ pub trait IoFactory { fn fs_open<P: PathLike>(&mut self, path: &P, fm: FileMode, fa: FileAccess) -> Result<~RtioFileStream, IoError>; fn fs_unlink<P: PathLike>(&mut self, path: &P) -> Result<(), IoError>; + fn pipe_init(&mut self, ipc: bool) -> Result<~RtioPipeObject, IoError>; + fn spawn(&mut self, config: &RtioProcessConfig) -> Result<~RtioProcessObject, IoError>; +} + +pub trait RtioStream { + fn read(&mut self, buf: &mut [u8]) -> Result<uint, IoError>; + fn write(&mut self, buf: &[u8]) -> Result<(), IoError>; } pub trait RtioTcpListener : RtioSocket { @@ -80,9 +92,7 @@ pub trait RtioTcpListener : RtioSocket { fn dont_accept_simultaneously(&mut self) -> Result<(), IoError>; } -pub trait RtioTcpStream : RtioSocket { - fn read(&mut self, buf: &mut [u8]) -> Result<uint, IoError>; - fn write(&mut self, buf: &[u8]) -> Result<(), IoError>; +pub trait RtioTcpStream : RtioSocket + RtioStream { fn peer_name(&mut self) -> Result<SocketAddr, IoError>; fn control_congestion(&mut self) -> Result<(), IoError>; fn nodelay(&mut self) -> Result<(), IoError>; @@ -124,3 +134,9 @@ pub trait RtioFileStream { fn tell(&self) -> Result<u64, IoError>; fn flush(&mut self) -> Result<(), IoError>; } + +pub trait RtioProcess { + fn id(&self) -> libc::pid_t; + fn kill(&mut self, signal: int) -> Result<(), IoError>; + fn wait(&mut self) -> int; +} |
