pub fn new(loop_: &mut Loop, cb: ~Callback) -> AsyncWatcher {
let handle = UvHandle::alloc(None::<AsyncWatcher>, uvll::UV_ASYNC);
assert_eq!(unsafe {
- uvll::async_init(loop_.native_handle(), handle, async_cb)
+ uvll::uv_async_init(loop_.native_handle(), handle, async_cb)
}, 0);
let flag = Exclusive::new(false);
let payload = ~Payload { callback: cb, exit_flag: flag.clone() };
impl UvHandle<uvll::uv_async_t> for AsyncWatcher {
fn uv_handle(&self) -> *uvll::uv_async_t { self.handle }
- unsafe fn from_uv_handle<'a>(h: &'a *T) -> &'a mut AsyncWatcher {
+ unsafe fn from_uv_handle<'a>(_: &'a *uvll::uv_async_t) -> &'a mut AsyncWatcher {
fail!("async watchers can't be built from their handles");
}
}
payload.callback.call();
if should_exit {
- unsafe { uvll::close(handle, close_cb) }
+ unsafe { uvll::uv_close(handle, close_cb) }
}
}
impl RemoteCallback for AsyncWatcher {
fn fire(&mut self) {
- unsafe { uvll::async_send(self.handle) }
+ unsafe { uvll::uv_async_send(self.handle) }
}
}
// signal and see the exit flag, destroying the handle
// before the final send.
*should_exit = true;
- uvll::async_send(self.handle)
+ uvll::uv_async_send(self.handle)
}
}
}
use std::c_str::CString;
use std::cast::transmute;
use std::libc;
-use std::libc::{c_int, c_char, c_void};
+use std::libc::{c_int, c_char, c_void, c_uint};
use super::{Request, NativeHandle, Loop, FsCallback, Buf,
status_to_maybe_uv_error, UvError};
self.sync_cleanup(result)
}
-<<<<<<< HEAD
pub fn close(mut self, loop_: &Loop, fd: c_int, cb: FsCallback) {
let complete_cb_ptr = self.req_boilerplate(Some(cb));
assert_eq!(unsafe {
- uvll::fs_close(loop_.native_handle(), self.native_handle(),
- fd, complete_cb_ptr)
- }, 0);
-=======
- pub fn close(self, loop_: &Loop, fd: c_int, cb: FsCallback) {
- let complete_cb_ptr = {
- let mut me = self;
- me.req_boilerplate(Some(cb))
- };
- let ret = unsafe {
uvll::uv_fs_close(loop_.native_handle(), self.native_handle(),
fd, complete_cb_ptr)
- };
- assert_eq!(ret, 0);
->>>>>>> 1850d26... Remove lots of uv/C++ wrappers
+ }, 0);
}
pub fn close_sync(mut self, loop_: &Loop,
fd: c_int) -> Result<c_int, UvError> {
self.sync_cleanup(result)
}
-<<<<<<< HEAD
pub fn mkdir(mut self, loop_: &Loop, path: &CString, mode: c_int,
cb: FsCallback) {
let complete_cb_ptr = self.req_boilerplate(Some(cb));
assert_eq!(path.with_ref(|p| unsafe {
- uvll::fs_mkdir(loop_.native_handle(),
- self.native_handle(), p, mode, complete_cb_ptr)
+ uvll::uv_fs_mkdir(loop_.native_handle(),
+ self.native_handle(), p, mode, complete_cb_ptr)
}), 0);
}
pub fn rmdir(mut self, loop_: &Loop, path: &CString, cb: FsCallback) {
let complete_cb_ptr = self.req_boilerplate(Some(cb));
assert_eq!(path.with_ref(|p| unsafe {
- uvll::fs_rmdir(loop_.native_handle(),
- self.native_handle(), p, complete_cb_ptr)
+ uvll::uv_fs_rmdir(loop_.native_handle(),
+ self.native_handle(), p, complete_cb_ptr)
}), 0);
}
cb: FsCallback) {
let complete_cb_ptr = self.req_boilerplate(Some(cb));
assert_eq!(unsafe {
- uvll::fs_rename(loop_.native_handle(),
- self.native_handle(),
- path.with_ref(|p| p),
- to.with_ref(|p| p),
- complete_cb_ptr)
+ uvll::uv_fs_rename(loop_.native_handle(),
+ self.native_handle(),
+ path.with_ref(|p| p),
+ to.with_ref(|p| p),
+ complete_cb_ptr)
}, 0);
}
cb: FsCallback) {
let complete_cb_ptr = self.req_boilerplate(Some(cb));
assert_eq!(path.with_ref(|p| unsafe {
- uvll::fs_chmod(loop_.native_handle(), self.native_handle(), p, mode,
- complete_cb_ptr)
+ uvll::uv_fs_chmod(loop_.native_handle(), self.native_handle(), p,
+ mode, complete_cb_ptr)
}), 0);
-=======
- pub fn mkdir(self, loop_: &Loop, path: &CString, mode: int, cb: FsCallback) {
- let complete_cb_ptr = {
- let mut me = self;
- me.req_boilerplate(Some(cb))
- };
- let ret = path.with_ref(|p| unsafe {
- uvll::uv_fs_mkdir(loop_.native_handle(),
- self.native_handle(), p,
- mode as c_int, complete_cb_ptr)
- });
- assert_eq!(ret, 0);
- }
-
- pub fn rmdir(self, loop_: &Loop, path: &CString, cb: FsCallback) {
- let complete_cb_ptr = {
- let mut me = self;
- me.req_boilerplate(Some(cb))
- };
- let ret = path.with_ref(|p| unsafe {
- uvll::uv_fs_rmdir(loop_.native_handle(),
- self.native_handle(), p, complete_cb_ptr)
- });
- assert_eq!(ret, 0);
->>>>>>> 1850d26... Remove lots of uv/C++ wrappers
}
pub fn readdir(mut self, loop_: &Loop, path: &CString,
flags: c_int, cb: FsCallback) {
-<<<<<<< HEAD
let complete_cb_ptr = self.req_boilerplate(Some(cb));
assert_eq!(path.with_ref(|p| unsafe {
- uvll::fs_readdir(loop_.native_handle(),
- self.native_handle(), p, flags, complete_cb_ptr)
+ uvll::uv_fs_readdir(loop_.native_handle(),
+ self.native_handle(), p, flags, complete_cb_ptr)
}), 0);
}
uvll::uv_fs_fdatasync(loop_.native_handle(), self.native_handle(), fd,
complete_cb_ptr)
}, 0);
-=======
- let complete_cb_ptr = {
- let mut me = self;
- me.req_boilerplate(Some(cb))
- };
- let ret = path.with_ref(|p| unsafe {
- uvll::uv_fs_readdir(loop_.native_handle(),
- self.native_handle(), p, flags, complete_cb_ptr)
- });
- assert_eq!(ret, 0);
->>>>>>> 1850d26... Remove lots of uv/C++ wrappers
}
// accessors/utility funcs
pub fn new(loop_: &mut Loop) -> ~IdleWatcher {
let handle = UvHandle::alloc(None::<IdleWatcher>, uvll::UV_IDLE);
assert_eq!(unsafe {
- uvll::idle_init(loop_.native_handle(), handle)
+ uvll::uv_idle_init(loop_.native_handle(), handle)
}, 0);
let me = ~IdleWatcher {
handle: handle,
pub fn onetime(loop_: &mut Loop, f: proc()) {
let handle = UvHandle::alloc(None::<IdleWatcher>, uvll::UV_IDLE);
unsafe {
- assert_eq!(uvll::idle_init(loop_.native_handle(), handle), 0);
+ assert_eq!(uvll::uv_idle_init(loop_.native_handle(), handle), 0);
let data: *c_void = cast::transmute(~f);
uvll::set_data_for_uv_handle(handle, data);
- assert_eq!(uvll::idle_start(handle, onetime_cb), 0)
+ assert_eq!(uvll::uv_idle_start(handle, onetime_cb), 0)
}
extern fn onetime_cb(handle: *uvll::uv_idle_t, status: c_int) {
let data = uvll::get_data_for_uv_handle(handle);
let f: ~proc() = cast::transmute(data);
(*f)();
- uvll::idle_stop(handle);
- uvll::close(handle, close_cb);
+ uvll::uv_idle_stop(handle);
+ uvll::uv_close(handle, close_cb);
}
}
fn start(&mut self, cb: ~Callback) {
assert!(self.callback.is_none());
self.callback = Some(cb);
- assert_eq!(unsafe { uvll::idle_start(self.handle, idle_cb) }, 0)
+ assert_eq!(unsafe { uvll::uv_idle_start(self.handle, idle_cb) }, 0)
self.idle_flag = true;
}
fn pause(&mut self) {
if self.idle_flag == true {
- assert_eq!(unsafe {uvll::idle_stop(self.handle) }, 0);
+ assert_eq!(unsafe {uvll::uv_idle_stop(self.handle) }, 0);
self.idle_flag = false;
}
}
fn resume(&mut self) {
if self.idle_flag == false {
- assert_eq!(unsafe { uvll::idle_start(self.handle, idle_cb) }, 0)
+ assert_eq!(unsafe { uvll::uv_idle_start(self.handle, idle_cb) }, 0)
self.idle_flag = true;
}
}
use std::vec;
use std::ptr;
use std::str;
-use std::libc::{c_void, c_int, size_t, malloc, free, c_char, c_uint};
+use std::libc::{c_void, c_int, size_t, malloc, free};
use std::cast::transmute;
use std::ptr::null;
use std::unstable::finally::Finally;
unsafe {
uvll::set_data_for_uv_handle(self.uv_handle(), null::<()>());
- uvll::close(self.uv_handle(), close_cb)
+ uvll::uv_close(self.uv_handle() as *uvll::uv_handle_t, close_cb)
}
}
}
}
fn kill(&mut self, signal: int) -> Result<(), IoError> {
- do self.home_for_io |self_| {
- match unsafe {
- uvll::process_kill(self_.handle, signal as libc::c_int)
- } {
- 0 => Ok(()),
- err => Err(uv_error_to_io_error(UvError(err)))
- }
+ let _m = self.fire_missiles();
+ match unsafe {
+ uvll::uv_process_kill(self.handle, signal as libc::c_int)
+ } {
+ 0 => Ok(()),
+ err => Err(uv_error_to_io_error(UvError(err)))
}
}
fn wait(&mut self) -> int {
// Make sure (on the home scheduler) that we have an exit status listed
- do self.home_for_io |self_| {
- match self_.exit_status {
- Some(*) => {}
- None => {
- // If there's no exit code previously listed, then the
- // process's exit callback has yet to be invoked. We just
- // need to deschedule ourselves and wait to be reawoken.
- let scheduler: ~Scheduler = Local::take();
- do scheduler.deschedule_running_task_and_then |_, task| {
- assert!(self_.to_wake.is_none());
- self_.to_wake = Some(task);
- }
- assert!(self_.exit_status.is_some());
+ let _m = self.fire_missiles();
+ match self.exit_status {
+ Some(*) => {}
+ None => {
+ // If there's no exit code previously listed, then the
+ // process's exit callback has yet to be invoked. We just
+ // need to deschedule ourselves and wait to be reawoken.
+ let scheduler: ~Scheduler = Local::take();
+ do scheduler.deschedule_running_task_and_then |_, task| {
+ assert!(self.to_wake.is_none());
+ self.to_wake = Some(task);
}
+ assert!(self.exit_status.is_some());
}
}
impl Drop for Process {
fn drop(&mut self) {
- do self.home_for_io |self_| {
- assert!(self_.to_wake.is_none());
- self_.close_async_();
- }
+ let _m = self.fire_missiles();
+ assert!(self.to_wake.is_none());
+ self.close_async_();
}
}
channel: SharedChan<Signum>) -> Result<~SignalWatcher, UvError> {
let handle = UvHandle::alloc(None::<SignalWatcher>, uvll::UV_SIGNAL);
assert_eq!(unsafe {
- uvll::signal_init(loop_.native_handle(), handle)
+ uvll::uv_signal_init(loop_.native_handle(), handle)
}, 0);
- match unsafe { uvll::signal_start(handle, signal_cb, signum as c_int) } {
+ match unsafe { uvll::uv_signal_start(handle, signal_cb, signum as c_int) } {
0 => {
let s = ~SignalWatcher {
handle: handle,
impl Drop for SignalWatcher {
fn drop(&mut self) {
- do self.home_for_io |self_| {
- self_.close_async_();
- }
+ let _m = self.fire_missiles();
+ self.close_async_();
}
}
pub fn new(loop_: &mut Loop) -> ~TimerWatcher {
let handle = UvHandle::alloc(None::<TimerWatcher>, uvll::UV_TIMER);
assert_eq!(unsafe {
- uvll::timer_init(loop_.native_handle(), handle)
+ uvll::uv_timer_init(loop_.native_handle(), handle)
}, 0);
let me = ~TimerWatcher {
handle: handle,
fn start(&mut self, msecs: u64, period: u64) {
assert_eq!(unsafe {
- uvll::timer_start(self.handle, timer_cb, msecs, period)
+ uvll::uv_timer_start(self.handle, timer_cb, msecs, period)
}, 0)
}
fn stop(&mut self) {
- assert_eq!(unsafe { uvll::timer_stop(self.handle) }, 0)
+ assert_eq!(unsafe { uvll::uv_timer_stop(self.handle) }, 0)
}
}
impl RtioTimer for TimerWatcher {
fn sleep(&mut self, msecs: u64) {
- do self.home_for_io_with_sched |self_, scheduler| {
- do scheduler.deschedule_running_task_and_then |_sched, task| {
- self_.action = Some(WakeTask(task));
- self_.start(msecs, 0);
- }
- self_.stop();
+ let (_m, sched) = self.fire_missiles_sched();
+ do sched.deschedule_running_task_and_then |_sched, task| {
+ self.action = Some(WakeTask(task));
+ self.start(msecs, 0);
}
+ self.stop();
}
fn oneshot(&mut self, msecs: u64) -> PortOne<()> {
let (port, chan) = oneshot();
let chan = Cell::new(chan);
- do self.home_for_io |self_| {
- self_.action = Some(SendOnce(chan.take()));
- self_.start(msecs, 0);
- }
+ let _m = self.fire_missiles();
+ self.action = Some(SendOnce(chan.take()));
+ self.start(msecs, 0);
return port;
}
let (port, chan) = stream();
let chan = Cell::new(chan);
- do self.home_for_io |self_| {
- self_.action = Some(SendMany(chan.take()));
- self_.start(msecs, msecs);
- }
+ let _m = self.fire_missiles();
+ self.action = Some(SendMany(chan.take()));
+ self.start(msecs, msecs);
return port;
}
impl Drop for TimerWatcher {
fn drop(&mut self) {
- do self.home_for_io |self_| {
- self_.action = None;
- self_.stop();
- self_.close_async_();
- }
+ let _m = self.fire_missiles();
+ self.action = None;
+ self.stop();
+ self.close_async_();
}
}
use std::cell::Cell;
use std::clone::Clone;
use std::comm::{SharedChan, GenericChan};
+use std::libc;
use std::libc::{c_int, c_uint, c_void};
use std::ptr;
use std::str;
use std::rt::task::Task;
use std::path::{GenericPath, Path};
use std::libc::{lseek, off_t, O_CREAT, O_APPEND, O_TRUNC, O_RDWR, O_RDONLY,
- O_WRONLY, S_IRUSR, S_IWUSR, S_IRWXU};
-use std::rt::io::{FileMode, FileAccess, OpenOrCreate, Open, Create,
- CreateOrTruncate, Append, Truncate, Read, Write, ReadWrite,
+ O_WRONLY, S_IRUSR, S_IWUSR};
+use std::rt::io::{FileMode, FileAccess, Open,
+ Append, Truncate, Read, Write, ReadWrite,
FileStat};
use std::rt::io::signal::Signum;
use std::task;
do sched.deschedule_running_task_and_then |_, task| {
let task = Cell::new(task);
let req = file::FsRequest::new();
- do f(self_, req) |_, uverr| {
+ do f(self, req) |_, uverr| {
let res = match uverr {
None => Ok(()),
Some(err) => Err(uv_error_to_io_error(err))
fn rust_set_stdio_container_fd(c: *uv_stdio_container_t, fd: c_int);
fn rust_set_stdio_container_stream(c: *uv_stdio_container_t,
stream: *uv_stream_t);
+ fn rust_uv_process_pid(p: *uv_process_t) -> c_int;
}
// generic uv functions
flags: c_int, cb: uv_fs_cb) -> c_int)
externfn!(fn uv_fs_req_cleanup(req: *uv_fs_t))
externfn!(fn uv_fs_fsync(handle: *uv_loop_t, req: *uv_fs_t, file: c_int,
- cb: *u8) -> c_int)
+ cb: uv_fs_cb) -> c_int)
externfn!(fn uv_fs_fdatasync(handle: *uv_loop_t, req: *uv_fs_t, file: c_int,
- cb: *u8) -> c_int)
+ cb: uv_fs_cb) -> c_int)
externfn!(fn uv_fs_ftruncate(handle: *uv_loop_t, req: *uv_fs_t, file: c_int,
- offset: i64, cb: *u8) -> c_int)
+ offset: i64, cb: uv_fs_cb) -> c_int)
externfn!(fn uv_fs_readlink(handle: *uv_loop_t, req: *uv_fs_t, file: *c_char,
- cb: *u8) -> c_int)
+ cb: uv_fs_cb) -> c_int)
externfn!(fn uv_fs_symlink(handle: *uv_loop_t, req: *uv_fs_t, src: *c_char,
- dst: *c_char, flags: c_int, cb: *u8) -> c_int)
+ dst: *c_char, flags: c_int, cb: uv_fs_cb) -> c_int)
+externfn!(fn uv_fs_rename(handle: *uv_loop_t, req: *uv_fs_t, src: *c_char,
+ dst: *c_char, cb: uv_fs_cb) -> c_int)
externfn!(fn uv_fs_link(handle: *uv_loop_t, req: *uv_fs_t, src: *c_char,
- dst: *c_char, cb: *u8) -> c_int)
+ dst: *c_char, cb: uv_fs_cb) -> c_int)
externfn!(fn uv_fs_chown(handle: *uv_loop_t, req: *uv_fs_t, src: *c_char,
- uid: uv_uid_t, gid: uv_gid_t, cb: *u8) -> c_int)
+ uid: uv_uid_t, gid: uv_gid_t, cb: uv_fs_cb) -> c_int)
+externfn!(fn uv_fs_chmod(handle: *uv_loop_t, req: *uv_fs_t, path: *c_char,
+ mode: c_int, cb: uv_fs_cb) -> c_int)
externfn!(fn uv_fs_lstat(handle: *uv_loop_t, req: *uv_fs_t, file: *c_char,
- cb: *u8) -> c_int)
+ cb: uv_fs_cb) -> c_int)
// getaddrinfo
externfn!(fn uv_getaddrinfo(loop_: *uv_loop_t, req: *uv_getaddrinfo_t,