about summary refs log tree commit diff
path: root/src/libstd/unstable
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2013-12-05 18:19:06 -0800
committerAlex Crichton <alex@alexcrichton.com>2013-12-16 17:47:11 -0800
commit529e268ab900f1b6e731af64ce2aeecda3555f4e (patch)
tree7ebb9ed2a7f36455b9550749a442522d45f0dc30 /src/libstd/unstable
parentbfa9064ba2687eb1d95708f72f41ddd9729a6ba1 (diff)
downloadrust-529e268ab900f1b6e731af64ce2aeecda3555f4e.tar.gz
rust-529e268ab900f1b6e731af64ce2aeecda3555f4e.zip
Fallout of rewriting std::comm
Diffstat (limited to 'src/libstd/unstable')
-rw-r--r--src/libstd/unstable/mod.rs13
-rw-r--r--src/libstd/unstable/sync.rs23
2 files changed, 12 insertions, 24 deletions
diff --git a/src/libstd/unstable/mod.rs b/src/libstd/unstable/mod.rs
index f8e2ea54f44..043d99eb1b8 100644
--- a/src/libstd/unstable/mod.rs
+++ b/src/libstd/unstable/mod.rs
@@ -10,10 +10,7 @@
 
 #[doc(hidden)];
 
-use comm::{GenericChan, GenericPort};
-use comm;
 use prelude::*;
-use task;
 use libc::uintptr_t;
 
 pub mod dynamic_lib;
@@ -38,15 +35,7 @@ a normal large stack.
 */
 pub fn run_in_bare_thread(f: proc()) {
     use rt::thread::Thread;
-
-    let (port, chan) = comm::stream();
-    // FIXME #4525: Unfortunate that this creates an extra scheduler but it's
-    // necessary since rust_raw_thread_join is blocking
-    do task::spawn_sched(task::SingleThreaded) {
-        Thread::start(f).join();
-        chan.send(());
-    }
-    port.recv();
+    Thread::start(f).join()
 }
 
 #[test]
diff --git a/src/libstd/unstable/sync.rs b/src/libstd/unstable/sync.rs
index 2dd5515bdbc..50fae1e0239 100644
--- a/src/libstd/unstable/sync.rs
+++ b/src/libstd/unstable/sync.rs
@@ -9,7 +9,7 @@
 // except according to those terms.
 
 use cast;
-use comm;
+use comm::{Chan, Port};
 use ptr;
 use option::{Option,Some,None};
 use task;
@@ -56,7 +56,7 @@ struct ArcData<T> {
     // drops the last refcount on an arc. Unfortunately this can't be a proper
     // pipe protocol because the unwrapper has to access both stages at once.
     // FIXME(#7544): Maybe use AtomicPtr instead (to avoid xchg in take() later)?
-    unwrapper: AtomicOption<(comm::ChanOne<()>, comm::PortOne<bool>)>,
+    unwrapper: AtomicOption<(Chan<()>, Port<bool>)>,
     // FIXME(#3224) should be able to make this non-option to save memory
     data: Option<T>,
 }
@@ -70,7 +70,7 @@ unsafe fn new_inner<T: Send>(data: T, refcount: uint) -> *mut ArcData<T> {
 
 /// A helper object used by `UnsafeArc::unwrap`.
 struct ChannelAndDataGuard<T> {
-    channel: Option<comm::ChanOne<bool>>,
+    channel: Option<Chan<bool>>,
     data: Option<~ArcData<T>>,
 }
 
@@ -92,7 +92,7 @@ impl<T> Drop for ChannelAndDataGuard<T> {
 }
 
 impl<T> ChannelAndDataGuard<T> {
-    fn unwrap(mut self) -> (comm::ChanOne<bool>, ~ArcData<T>) {
+    fn unwrap(mut self) -> (Chan<bool>, ~ArcData<T>) {
         (self.channel.take_unwrap(), self.data.take_unwrap())
     }
 }
@@ -167,8 +167,8 @@ impl<T: Send> UnsafeArc<T> {
             // The ~ dtor needs to run if this code succeeds.
             let mut data: ~ArcData<T> = cast::transmute(this.data);
             // Set up the unwrap protocol.
-            let (p1,c1) = comm::oneshot(); // ()
-            let (p2,c2) = comm::oneshot(); // bool
+            let (p1,c1) = Chan::new(); // ()
+            let (p2,c2) = Chan::new(); // bool
             // Try to put our server end in the unwrapper slot.
             // This needs no barrier -- it's protected by the release barrier on
             // the xadd, and the acquire+release barrier in the destructor's xadd.
@@ -269,7 +269,7 @@ impl<T> Drop for UnsafeArc<T>{
                 // reference. In effect, being here means we're the only
                 // *awake* task with the data.
                 match data.unwrapper.take(Acquire) {
-                    Some(~(message,response)) => {
+                    Some(~(message, response)) => {
                         // Send 'ready' and wait for a response.
                         message.send(());
                         // Unkillable wait. Message guaranteed to come.
@@ -508,7 +508,6 @@ impl<T:Send> Exclusive<T> {
 
 #[cfg(test)]
 mod tests {
-    use comm;
     use option::*;
     use prelude::*;
     use super::{Exclusive, UnsafeArc, atomic};
@@ -541,10 +540,10 @@ mod tests {
 
             for _ in range(0u, num_tasks) {
                 let total = total.clone();
-                let (port, chan) = comm::stream();
+                let (port, chan) = Chan::new();
                 futures.push(port);
 
-                do task::spawn || {
+                do task::spawn {
                     for _ in range(0u, count) {
                         total.with(|count| **count += 1);
                     }
@@ -552,7 +551,7 @@ mod tests {
                 }
             };
 
-            for f in futures.iter() { f.recv() }
+            for f in futures.mut_iter() { f.recv() }
 
             total.with(|total| assert!(**total == num_tasks * count));
         }
@@ -625,7 +624,7 @@ mod tests {
         // When an unwrap and a try_unwrap race, the unwrapper should always win.
         let x = UnsafeArc::new(~~"hello");
         let x2 = x.clone();
-        let (p,c) = comm::stream();
+        let (p,c) = Chan::new();
         do task::spawn {
             c.send(());
             assert!(x2.unwrap() == ~~"hello");