]> git.lizzy.rs Git - rust.git/commitdiff
std: minor timer cleanup based on feedback
authorJeff Olson <olson.jeffery@gmail.com>
Fri, 19 Jul 2013 23:22:13 +0000 (16:22 -0700)
committerJeff Olson <olson.jeffery@gmail.com>
Mon, 22 Jul 2013 20:19:04 +0000 (13:19 -0700)
src/libstd/rt/io/mod.rs
src/libstd/rt/io/timer.rs

index e261b3a3c579d1a6fcbeb260e998d20a728efedf..838c2d86c9fa267607df1002b342cd8e33dbf1bf 100644 (file)
@@ -298,7 +298,7 @@ pub mod net {
 mod support;
 
 /// Basic Timer
-mod timer;
+pub mod timer;
 
 /// Thread-blocking implementations
 pub mod native {
index 1a5fc66f183f432746a5872e7a51da3f1a7864d3..f80a91e988c22b17d2295522bd350ca1149a1f01 100644 (file)
 pub struct Timer(~RtioTimerObject);
 
 impl Timer {
-    fn new(i: ~RtioTimerObject) -> Timer {
+    fn new_on_rt(i: ~RtioTimerObject) -> Timer {
         Timer(i)
     }
 
-    pub fn init() -> Option<Timer> {
+    pub fn new() -> Option<Timer> {
         let timer = unsafe {
             rtdebug!("Timer::init: borrowing io to init timer");
             let io = Local::unsafe_borrow::<IoFactoryObject>();
@@ -29,7 +29,7 @@ pub fn init() -> Option<Timer> {
             (*io).timer_init()
         };
         match timer {
-            Ok(t) => Some(Timer::new(t)),
+            Ok(t) => Some(Timer::new_on_rt(t)),
             Err(ioerr) => {
                 rtdebug!("Timer::init: failed to init: %?", ioerr);
                 io_error::cond.raise(ioerr);
@@ -53,7 +53,7 @@ mod test {
     #[test]
     fn test_io_timer_sleep_simple() {
         do run_in_newsched_task {
-            let timer = Timer::init();
+            let timer = Timer::new();
             match timer {
                 Some(t) => t.sleep(1),
                 None => assert!(false)