about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2013-12-13 18:25:26 -0800
committerAlex Crichton <alex@alexcrichton.com>2013-12-24 19:59:54 -0800
commit7f483459045789d6bb44671269fd9aec73dbeb63 (patch)
treee6454b48db1cafd14dc2dc29a1355fc9f710bbb8 /src/libstd
parent1c4af5e3d93fe2953c31f8a76ee2aed15069204a (diff)
downloadrust-7f483459045789d6bb44671269fd9aec73dbeb63.tar.gz
rust-7f483459045789d6bb44671269fd9aec73dbeb63.zip
std: Remove must deferred sending functions
These functions are all unnecessary now, and they only have meaning in the M:N
context. Removing these functions uncovered a bug in the librustuv timer
bindings, but it was fairly easy to cover (and the test is already committed).

These cannot be completely removed just yet due to their usage in the WaitQueue
of extra::sync, and until the mutex in libextra is rewritten it will not be
possible to remove the deferred sends for channels.
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/comm/mod.rs39
1 files changed, 5 insertions, 34 deletions
diff --git a/src/libstd/comm/mod.rs b/src/libstd/comm/mod.rs
index ae440894b4e..21db234122b 100644
--- a/src/libstd/comm/mod.rs
+++ b/src/libstd/comm/mod.rs
@@ -496,7 +496,7 @@ impl Packet {
         match self.channels.fetch_sub(1, SeqCst) {
             1 => {
                 match self.cnt.swap(DISCONNECTED, SeqCst) {
-                    -1 => { self.wakeup(false); }
+                    -1 => { self.wakeup(true); }
                     DISCONNECTED => {}
                     n => { assert!(n >= 0); }
                 }
@@ -537,9 +537,6 @@ impl<T: Send> Chan<T> {
     /// port.
     ///
     /// Rust channels are infinitely buffered so this method will never block.
-    /// This method may trigger a rescheduling, however, in order to wake up a
-    /// blocked receiver (if one is present). If no scheduling is desired, then
-    /// the `send_deferred` guarantees that there will be no reschedulings.
     ///
     /// # Failure
     ///
@@ -561,15 +558,6 @@ impl<T: Send> Chan<T> {
         }
     }
 
-    /// This function is equivalent in the semantics of `send`, but it
-    /// guarantees that a rescheduling will never occur when this method is
-    /// called.
-    pub fn send_deferred(&self, t: T) {
-        if !self.try_send_deferred(t) {
-            fail!("sending on a closed channel");
-        }
-    }
-
     /// Attempts to send a value on this channel, returning whether it was
     /// successfully sent.
     ///
@@ -585,9 +573,8 @@ impl<T: Send> Chan<T> {
     /// be tolerated, then this method should be used instead.
     pub fn try_send(&self, t: T) -> bool { self.try(t, true) }
 
-    /// This function is equivalent in the semantics of `try_send`, but it
-    /// guarantees that a rescheduling will never occur when this method is
-    /// called.
+    /// This function will not stick around for very long. The purpose of this
+    /// function is to guarantee that no rescheduling is performed.
     pub fn try_send_deferred(&self, t: T) -> bool { self.try(t, false) }
 
     fn try(&self, t: T, can_resched: bool) -> bool {
@@ -649,25 +636,9 @@ impl<T: Send> SharedChan<T> {
         }
     }
 
-    /// This function is equivalent in the semantics of `send`, but it
-    /// guarantees that a rescheduling will never occur when this method is
-    /// called.
-    pub fn send_deferred(&self, t: T) {
-        if !self.try_send_deferred(t) {
-            fail!("sending on a closed channel");
-        }
-    }
-
     /// Equivalent method to `try_send` on the `Chan` type (using the same
     /// semantics)
-    pub fn try_send(&self, t: T) -> bool { self.try(t, true) }
-
-    /// This function is equivalent in the semantics of `try_send`, but it
-    /// guarantees that a rescheduling will never occur when this method is
-    /// called.
-    pub fn try_send_deferred(&self, t: T) -> bool { self.try(t, false) }
-
-    fn try(&self, t: T, can_resched: bool) -> bool {
+    pub fn try_send(&self, t: T) -> bool {
         unsafe {
             // Note that the multiple sender case is a little tricker
             // semantically than the single sender case. The logic for
@@ -704,7 +675,7 @@ impl<T: Send> SharedChan<T> {
 
             match (*packet).increment() {
                 DISCONNECTED => {} // oh well, we tried
-                -1 => { (*packet).wakeup(can_resched); }
+                -1 => { (*packet).wakeup(true); }
                 n => {
                     if n > 0 && n % RESCHED_FREQ == 0 {
                         let task: ~Task = Local::take();