about summary refs log tree commit diff
path: root/src/libstd/io/timer.rs
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2013-12-05 17:25:48 -0800
committerPatrick Walton <pcwalton@mimiga.net>2013-12-10 15:13:12 -0800
commit6bd80f74505a3eb7c44753c69cbe253ff566d5c1 (patch)
treeacccb99cf7a8bae4571c1e866415c0731a6f0f37 /src/libstd/io/timer.rs
parent8c2ebe1622681c2a93a2fcf2673a5671fd110ead (diff)
downloadrust-6bd80f74505a3eb7c44753c69cbe253ff566d5c1.tar.gz
rust-6bd80f74505a3eb7c44753c69cbe253ff566d5c1.zip
librustuv: Change `with_local_io` to use RAII.
Diffstat (limited to 'src/libstd/io/timer.rs')
-rw-r--r--src/libstd/io/timer.rs20
1 files changed, 9 insertions, 11 deletions
diff --git a/src/libstd/io/timer.rs b/src/libstd/io/timer.rs
index 8dda7935888..202e02d55d0 100644
--- a/src/libstd/io/timer.rs
+++ b/src/libstd/io/timer.rs
@@ -42,7 +42,7 @@ use comm::{Port, PortOne};
 use option::{Option, Some, None};
 use result::{Ok, Err};
 use io::io_error;
-use rt::rtio::{IoFactory, RtioTimer, with_local_io};
+use rt::rtio::{IoFactory, LocalIo, RtioTimer};
 
 pub struct Timer {
     priv obj: ~RtioTimer
@@ -60,17 +60,15 @@ impl Timer {
     /// for a number of milliseconds, or to possibly create channels which will
     /// get notified after an amount of time has passed.
     pub fn new() -> Option<Timer> {
-        with_local_io(|io| {
-            match io.timer_init() {
-                Ok(t) => Some(Timer { obj: t }),
-                Err(ioerr) => {
-                    debug!("Timer::init: failed to init: {:?}", ioerr);
-                    io_error::cond.raise(ioerr);
-                    None
-                }
+        let mut io = LocalIo::borrow();
+        match io.get().timer_init() {
+            Ok(t) => Some(Timer { obj: t }),
+            Err(ioerr) => {
+                debug!("Timer::init: failed to init: {:?}", ioerr);
+                io_error::cond.raise(ioerr);
+                None
             }
-
-        })
+        }
     }
 
     /// Blocks the current task for `msecs` milliseconds.