about summary refs log tree commit diff
path: root/src/libstd/timer.rs
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2013-05-03 14:20:34 -0700
committerPatrick Walton <pcwalton@mimiga.net>2013-05-08 17:03:59 -0700
commit6a44482b175a5486039fd5f2fd32f1051ce80e50 (patch)
tree818881a061a2ece4bc5d1fe86952b0fbc5a981f9 /src/libstd/timer.rs
parent803a4f45fa5b581155e638143afb97195cfa9f2e (diff)
downloadrust-6a44482b175a5486039fd5f2fd32f1051ce80e50.tar.gz
rust-6a44482b175a5486039fd5f2fd32f1051ce80e50.zip
libcore: Remove mutable fields from pipes
Diffstat (limited to 'src/libstd/timer.rs')
-rw-r--r--src/libstd/timer.rs35
1 files changed, 21 insertions, 14 deletions
diff --git a/src/libstd/timer.rs b/src/libstd/timer.rs
index b19b2f2889e..76aa4d615e1 100644
--- a/src/libstd/timer.rs
+++ b/src/libstd/timer.rs
@@ -14,10 +14,11 @@ use uv;
 use uv::iotask;
 use uv::iotask::IoTask;
 
-use core::libc;
-use core::libc::c_void;
 use core::cast::transmute;
+use core::cast;
 use core::comm::{stream, Chan, SharedChan, Port, select2i};
+use core::libc::c_void;
+use core::libc;
 
 /**
  * Wait for timeout period then send provided value over a channel
@@ -120,22 +121,28 @@ pub fn sleep(iotask: &IoTask, msecs: uint) {
 pub fn recv_timeout<T:Copy + Owned>(iotask: &IoTask,
                                    msecs: uint,
                                    wait_po: &Port<T>)
-                                -> Option<T> {
-    let (timeout_po, timeout_ch) = stream::<()>();
+                                   -> Option<T> {
+    let mut (timeout_po, timeout_ch) = stream::<()>();
     delayed_send(iotask, msecs, &timeout_ch, ());
-    // FIXME: This could be written clearer (#2618)
-    either::either(
-        |_| {
-            None
-        }, |_| {
-            Some(wait_po.recv())
-        }, &select2i(&timeout_po, wait_po)
-    )
+
+    // XXX: Workaround due to ports and channels not being &mut. They should
+    // be.
+    unsafe {
+        let wait_po = cast::transmute_mut(wait_po);
+
+        // FIXME: This could be written clearer (#2618)
+        either::either(
+            |_| {
+                None
+            }, |_| {
+                Some(wait_po.recv())
+            }, &select2i(&mut timeout_po, wait_po)
+        )
+    }
 }
 
 // INTERNAL API
-extern fn delayed_send_cb(handle: *uv::ll::uv_timer_t,
-                                status: libc::c_int) {
+extern fn delayed_send_cb(handle: *uv::ll::uv_timer_t, status: libc::c_int) {
     unsafe {
         debug!(
             "delayed_send_cb handle %? status %?", handle, status);