diff --git a/src/libgreen/sched.rs b/src/libgreen/sched.rs index b9144047df5..e0415470828 100644 --- a/src/libgreen/sched.rs +++ b/src/libgreen/sched.rs @@ -1029,6 +1029,7 @@ mod test { use std::rt::task::TaskOpts; use std::rt::task::Task; use std::rt::local::Local; + use std::time::Duration; use {TaskState, PoolConfig, SchedPool}; use basic; @@ -1291,7 +1292,7 @@ mod test { // doesn't exit before emptying the work queue pool.spawn(TaskOpts::new(), proc() { spawn(proc() { - timer::sleep(10); + timer::sleep(Duration::milliseconds(10)); }); }); diff --git a/src/libstd/io/net/tcp.rs b/src/libstd/io/net/tcp.rs index 76368ac2821..34ccf9e617a 100644 --- a/src/libstd/io/net/tcp.rs +++ b/src/libstd/io/net/tcp.rs @@ -171,13 +171,14 @@ impl TcpStream { /// # #![allow(unused_must_use)] /// use std::io::timer; /// use std::io::TcpStream; + /// use std::time::Duration; /// /// let mut stream = TcpStream::connect("127.0.0.1", 34254).unwrap(); /// let stream2 = stream.clone(); /// /// spawn(proc() { /// // close this stream after one second - /// timer::sleep(1000); + /// timer::sleep(Duration::seconds(1)); /// let mut stream = stream2; /// stream.close_read(); /// }); diff --git a/src/libstd/io/timer.rs b/src/libstd/io/timer.rs index 3045871ce7a..39c6c74e45e 100644 --- a/src/libstd/io/timer.rs +++ b/src/libstd/io/timer.rs @@ -38,15 +38,16 @@ use rt::rtio::{IoFactory, LocalIo, RtioTimer, Callback}; /// # fn main() {} /// # fn foo() { /// use std::io::Timer; +/// use std::time::Duration; /// /// let mut timer = Timer::new().unwrap(); -/// timer.sleep(10); // block the task for awhile +/// timer.sleep(Duration::milliseconds(10)); // block the task for awhile /// -/// let timeout = timer.oneshot(10); +/// let timeout = timer.oneshot(Duration::milliseconds(10)); /// // do some work /// timeout.recv(); // wait for the timeout to expire /// -/// let periodic = timer.periodic(10); +/// let periodic = timer.periodic(Duration::milliseconds(10)); /// loop { /// periodic.recv(); /// // this loop is only executed once every 10ms @@ -61,9 +62,10 @@ use rt::rtio::{IoFactory, LocalIo, RtioTimer, Callback}; /// # fn main() {} /// # fn foo() { /// use std::io::timer; +/// use std::time::Duration; /// /// // Put this task to sleep for 5 seconds -/// timer::sleep(5000); +/// timer::sleep(Duration::seconds(5)); /// # } /// ``` pub struct Timer { @@ -123,9 +125,10 @@ impl Timer { /// /// ```rust /// use std::io::Timer; + /// use std::time::Duration; /// /// let mut timer = Timer::new().unwrap(); - /// let ten_milliseconds = timer.oneshot(10); + /// let ten_milliseconds = timer.oneshot(Duration::milliseconds(10)); /// /// for _ in range(0u, 100) { /* do work */ } /// @@ -135,9 +138,10 @@ impl Timer { /// /// ```rust /// use std::io::Timer; + /// use std::time::Duration; /// /// // Incorrect, method chaining-style: - /// let mut five_ms = Timer::new().unwrap().oneshot(5); + /// let mut five_ms = Timer::new().unwrap().oneshot(Duration::milliseconds(5)); /// // The timer object was destroyed, so this will always fail: /// // five_ms.recv() /// ``` @@ -173,9 +177,10 @@ impl Timer { /// /// ```rust /// use std::io::Timer; + /// use std::time::Duration; /// /// let mut timer = Timer::new().unwrap(); - /// let ten_milliseconds = timer.periodic(10); + /// let ten_milliseconds = timer.periodic(Duration::milliseconds(10)); /// /// for _ in range(0u, 100) { /* do work */ } /// @@ -191,9 +196,10 @@ impl Timer { /// /// ```rust /// use std::io::Timer; + /// use std::time::Duration; /// /// // Incorrect, method chaining-style. - /// let mut five_ms = Timer::new().unwrap().periodic(5); + /// let mut five_ms = Timer::new().unwrap().periodic(Duration::milliseconds(5)); /// // The timer object was destroyed, so this will always fail: /// // five_ms.recv() /// ``` diff --git a/src/libsync/comm/mod.rs b/src/libsync/comm/mod.rs index 45016b97566..e4df661b562 100644 --- a/src/libsync/comm/mod.rs +++ b/src/libsync/comm/mod.rs @@ -128,10 +128,11 @@ //! //! ```no_run //! use std::io::timer::Timer; +//! use std::time::Duration; //! //! let (tx, rx) = channel::(); //! let mut timer = Timer::new().unwrap(); -//! let timeout = timer.oneshot(10000); +//! let timeout = timer.oneshot(Duration::seconds(10)); //! //! loop { //! select! { @@ -150,12 +151,13 @@ //! //! ```no_run //! use std::io::timer::Timer; +//! use std::time::Duration; //! //! let (tx, rx) = channel::(); //! let mut timer = Timer::new().unwrap(); //! //! loop { -//! let timeout = timer.oneshot(5000); +//! let timeout = timer.oneshot(Duration::seconds(5)); //! //! select! { //! val = rx.recv() => println!("Received {}", val), diff --git a/src/test/run-pass/core-run-destroy.rs b/src/test/run-pass/core-run-destroy.rs index 34f1e681608..9cee83a8598 100644 --- a/src/test/run-pass/core-run-destroy.rs +++ b/src/test/run-pass/core-run-destroy.rs @@ -25,6 +25,7 @@ extern crate green; extern crate rustuv; use std::io::{Process, Command}; +use std::time::Duration; macro_rules! succeed( ($e:expr) => ( match $e { Ok(..) => {}, Err(e) => fail!("failure: {}", e) } @@ -115,7 +116,7 @@ pub fn test_destroy_actually_kills(force: bool) { // Don't let this test time out, this should be quick let (tx, rx1) = channel(); let mut t = timer::Timer::new().unwrap(); - let rx2 = t.oneshot(1000); + let rx2 = t.oneshot(Duration::milliseconds(1000)); spawn(proc() { select! { () = rx2.recv() => unsafe { libc::exit(1) }, diff --git a/src/test/run-pass/issue-12684.rs b/src/test/run-pass/issue-12684.rs index 37e675b52eb..e21338746be 100644 --- a/src/test/run-pass/issue-12684.rs +++ b/src/test/run-pass/issue-12684.rs @@ -13,6 +13,8 @@ extern crate native; extern crate green; extern crate rustuv; +use std::time::Duration; + #[start] fn start(argc: int, argv: *const *const u8) -> int { green::start(argc, argv, rustuv::event_loop, main) @@ -24,6 +26,6 @@ fn main() { fn customtask() { let mut timer = std::io::timer::Timer::new().unwrap(); - let periodic = timer.periodic(10); + let periodic = timer.periodic(Duration::milliseconds(10)); periodic.recv(); } diff --git a/src/test/run-pass/issue-12699.rs b/src/test/run-pass/issue-12699.rs index c24128f97e3..6b6e770bc99 100644 --- a/src/test/run-pass/issue-12699.rs +++ b/src/test/run-pass/issue-12699.rs @@ -12,6 +12,7 @@ extern crate native; use std::io::timer; +use std::time::Duration; #[start] fn start(argc: int, argv: *const *const u8) -> int { @@ -19,5 +20,5 @@ fn start(argc: int, argv: *const *const u8) -> int { } fn main() { - timer::sleep(250); + timer::sleep(Duration::milliseconds(250)); } diff --git a/src/test/run-pass/issue-9396.rs b/src/test/run-pass/issue-9396.rs index 9f08f1db410..c16319a16f2 100644 --- a/src/test/run-pass/issue-9396.rs +++ b/src/test/run-pass/issue-9396.rs @@ -10,12 +10,13 @@ use std::comm; use std::io::timer::Timer; +use std::time::Duration; pub fn main() { let (tx, rx) = channel(); spawn(proc (){ let mut timer = Timer::new().unwrap(); - timer.sleep(10); + timer.sleep(Duration::milliseconds(10)); tx.send(()); }); loop { diff --git a/src/test/run-pass/tcp-connect-timeouts.rs b/src/test/run-pass/tcp-connect-timeouts.rs index 6f6fff15814..1bdd06ca0e9 100644 --- a/src/test/run-pass/tcp-connect-timeouts.rs +++ b/src/test/run-pass/tcp-connect-timeouts.rs @@ -38,6 +38,7 @@ macro_rules! iotest ( use std::io::net::tcp::*; use std::io::test::*; use std::io; + use std::time::Duration; fn f() $b @@ -72,7 +73,7 @@ iotest!(fn eventual_timeout() { let mut v = Vec::new(); for _ in range(0u, 10000) { - match TcpStream::connect_timeout(addr, 100) { + match TcpStream::connect_timeout(addr, Duration::milliseconds(100)) { Ok(e) => v.push(e), Err(ref e) if e.kind == io::TimedOut => return, Err(e) => fail!("other error: {}", e), @@ -87,11 +88,11 @@ iotest!(fn timeout_success() { let port = addr.port; let _l = TcpListener::bind(host.as_slice(), port).unwrap().listen(); - assert!(TcpStream::connect_timeout(addr, 1000).is_ok()); + assert!(TcpStream::connect_timeout(addr, Duration::milliseconds(1000)).is_ok()); }) iotest!(fn timeout_error() { let addr = next_test_ip4(); - assert!(TcpStream::connect_timeout(addr, 1000).is_err()); + assert!(TcpStream::connect_timeout(addr, Duration::milliseconds(1000)).is_err()); })