diff options
Diffstat (limited to 'src/libextra/timer.rs')
| -rw-r--r-- | src/libextra/timer.rs | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/src/libextra/timer.rs b/src/libextra/timer.rs index 7a4ad34b508..d957ac43801 100644 --- a/src/libextra/timer.rs +++ b/src/libextra/timer.rs @@ -10,18 +10,17 @@ //! Utilities that leverage libuv's `uv_timer_*` API -use core::prelude::*; use uv; use uv::iotask; use uv::iotask::IoTask; -use core::cast::transmute; -use core::cast; -use core::comm::{stream, Chan, SharedChan, Port, select2i}; -use core::either; -use core::libc::c_void; -use core::libc; +use std::cast::transmute; +use std::cast; +use std::comm::{stream, Chan, SharedChan, Port, select2i}; +use std::either; +use std::libc::c_void; +use std::libc; /** * Wait for timeout period then send provided value over a channel @@ -39,7 +38,7 @@ use core::libc; * * ch - a channel of type T to send a `val` on * * val - a value of type T to send over the provided `ch` */ -pub fn delayed_send<T:Owned>(iotask: &IoTask, +pub fn delayed_send<T:Send>(iotask: &IoTask, msecs: uint, ch: &Chan<T>, val: T) { @@ -111,7 +110,7 @@ pub fn sleep(iotask: &IoTask, msecs: uint) { * * * `iotask' - `uv::iotask` that the tcp request will run on * * msecs - an mount of time, in milliseconds, to wait to receive - * * wait_port - a `core::comm::port<T>` to receive on + * * wait_port - a `std::comm::port<T>` to receive on * * # Returns * @@ -119,11 +118,12 @@ pub fn sleep(iotask: &IoTask, msecs: uint) { * on the provided port in the allotted timeout period, then the result will * be a `Some(T)`. If not, then `None` will be returned. */ -pub fn recv_timeout<T:Copy + Owned>(iotask: &IoTask, +pub fn recv_timeout<T:Copy + Send>(iotask: &IoTask, msecs: uint, wait_po: &Port<T>) -> Option<T> { - let mut (timeout_po, timeout_ch) = stream::<()>(); + let (timeout_po, timeout_ch) = stream::<()>(); + let mut timeout_po = timeout_po; delayed_send(iotask, msecs, &timeout_ch, ()); // XXX: Workaround due to ports and channels not being &mut. They should @@ -175,16 +175,15 @@ extern fn delayed_send_close_cb(handle: *uv::ll::uv_timer_t) { #[cfg(test)] mod test { - use core::prelude::*; use timer::*; use uv; - use core::cell::Cell; - use core::pipes::{stream, SharedChan}; - use core::rand::RngUtil; - use core::rand; - use core::task; + use std::cell::Cell; + use std::pipes::{stream, SharedChan}; + use std::rand::RngUtil; + use std::rand; + use std::task; #[test] fn test_gl_timer_simple_sleep_test() { @@ -217,12 +216,12 @@ mod test { for repeat.times { let ch = ch.clone(); - for spec.each |spec| { + for spec.iter().advance |spec| { let (times, maxms) = *spec; let ch = ch.clone(); let hl_loop_clone = hl_loop.clone(); do task::spawn { - use core::rand::*; + use std::rand::*; let mut rng = rng(); for times.times { sleep(&hl_loop_clone, rng.next() as uint % maxms); |
