about summary refs log tree commit diff
path: root/src/libcore
diff options
context:
space:
mode:
authorEric Holk <eric.holk@gmail.com>2012-08-07 11:46:52 -0700
committerEric Holk <eric.holk@gmail.com>2012-08-07 11:47:12 -0700
commitabf4421e7c2fce4e768eb20c126989501081f4f9 (patch)
tree2f278276d0b59c31c5a8cbf077a6dd5efb9777d6 /src/libcore
parent672bfa5773913ce99524703e943729e3e50953b8 (diff)
Generate try_send versions for all the messages. Fixes #3128
Diffstat (limited to 'src/libcore')
-rw-r--r--src/libcore/pipes.rs45
1 files changed, 24 insertions, 21 deletions
diff --git a/src/libcore/pipes.rs b/src/libcore/pipes.rs
index e56bb456189..4fa3d18c2a7 100644
--- a/src/libcore/pipes.rs
+++ b/src/libcore/pipes.rs
@@ -337,7 +337,7 @@ struct buffer_resource<T: send> {
 
 #[doc(hidden)]
 fn send<T: send, Tbuffer: send>(-p: send_packet_buffered<T, Tbuffer>,
-                                -payload: T) {
+                                -payload: T) -> bool {
     let header = p.header();
     let p_ = p.unwrap();
     let p = unsafe { &*p_ };
@@ -346,29 +346,32 @@ fn send<T: send, Tbuffer: send>(-p: send_packet_buffered<T, Tbuffer>,
     p.payload <- some(payload);
     let old_state = swap_state_rel(p.header.state, full);
     match old_state {
-      empty => {
-        // Yay, fastpath.
+        empty => {
+            // Yay, fastpath.
 
-        // The receiver will eventually clean this up.
-        //unsafe { forget(p); }
-      }
-      full => fail ~"duplicate send",
-      blocked => {
-        debug!{"waking up task for %?", p_};
-        let old_task = swap_task(p.header.blocked_task, ptr::null());
-        if !old_task.is_null() {
-            rustrt::task_signal_event(
-                old_task, ptr::addr_of(p.header) as *libc::c_void);
-            rustrt::rust_task_deref(old_task);
+            // The receiver will eventually clean this up.
+            //unsafe { forget(p); }
+            return true;
         }
+        full => fail ~"duplicate send",
+        blocked => {
+            debug!{"waking up task for %?", p_};
+            let old_task = swap_task(p.header.blocked_task, ptr::null());
+            if !old_task.is_null() {
+                rustrt::task_signal_event(
+                    old_task, ptr::addr_of(p.header) as *libc::c_void);
+                rustrt::rust_task_deref(old_task);
+            }
 
-        // The receiver will eventually clean this up.
-        //unsafe { forget(p); }
-      }
-      terminated => {
-        // The receiver will never receive this. Rely on drop_glue
-        // to clean everything up.
-      }
+            // The receiver will eventually clean this up.
+            //unsafe { forget(p); }
+            return true;
+        }
+        terminated => {
+            // The receiver will never receive this. Rely on drop_glue
+            // to clean everything up.
+            return false;
+        }
     }
 }