about summary refs log tree commit diff
path: root/src/libstd/rt/mod.rs
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2013-12-03 16:44:16 -0800
committerPatrick Walton <pcwalton@mimiga.net>2013-12-10 15:13:12 -0800
commit786dea207d5b891d37e596e96dd2f84c4cb59f49 (patch)
treef275936b26e6602b11363446fcac5ad3b09dbe92 /src/libstd/rt/mod.rs
parent5aad292fb99f7e9a2730b35ed535bda0ab9c6117 (diff)
downloadrust-786dea207d5b891d37e596e96dd2f84c4cb59f49.tar.gz
rust-786dea207d5b891d37e596e96dd2f84c4cb59f49.zip
libextra: Another round of de-`Cell`-ing.
34 uses of `Cell` remain.
Diffstat (limited to 'src/libstd/rt/mod.rs')
-rw-r--r--src/libstd/rt/mod.rs33
1 files changed, 17 insertions, 16 deletions
diff --git a/src/libstd/rt/mod.rs b/src/libstd/rt/mod.rs
index 3d0222cefae..ce8d1ab1983 100644
--- a/src/libstd/rt/mod.rs
+++ b/src/libstd/rt/mod.rs
@@ -57,7 +57,6 @@ Several modules in `core` are clients of `rt`:
 // XXX: this should not be here.
 #[allow(missing_doc)];
 
-use cell::Cell;
 use clone::Clone;
 use container::Container;
 use iter::Iterator;
@@ -274,7 +273,7 @@ fn run_(main: proc(), use_main_sched: bool) -> int {
 
     let nscheds = util::default_sched_threads();
 
-    let main = Cell::new(main);
+    let mut main = Some(main);
 
     // The shared list of sleeping schedulers.
     let sleepers = SleeperList::new();
@@ -376,24 +375,24 @@ fn run_(main: proc(), use_main_sched: bool) -> int {
     };
 
     let mut threads = ~[];
-
-    let on_exit = Cell::new(on_exit);
+    let mut on_exit = Some(on_exit);
 
     if !use_main_sched {
 
         // In the case where we do not use a main_thread scheduler we
         // run the main task in one of our threads.
 
-        let mut main_task = ~Task::new_root(&mut scheds[0].stack_pool, None, main.take());
+        let mut main_task = ~Task::new_root(&mut scheds[0].stack_pool,
+                                            None,
+                                            ::util::replace(&mut main,
+                                                            None).unwrap());
         main_task.name = Some(SendStrStatic("<main>"));
-        main_task.death.on_exit = Some(on_exit.take());
-        let main_task_cell = Cell::new(main_task);
+        main_task.death.on_exit = ::util::replace(&mut on_exit, None);
 
         let sched = scheds.pop();
-        let sched_cell = Cell::new(sched);
+        let main_task = main_task;
         let thread = do Thread::start {
-            let sched = sched_cell.take();
-            sched.bootstrap(main_task_cell.take());
+            sched.bootstrap(main_task);
         };
         threads.push(thread);
     }
@@ -401,9 +400,8 @@ fn run_(main: proc(), use_main_sched: bool) -> int {
     // Run each remaining scheduler in a thread.
     for sched in scheds.move_rev_iter() {
         rtdebug!("creating regular schedulers");
-        let sched_cell = Cell::new(sched);
         let thread = do Thread::start {
-            let mut sched = sched_cell.take();
+            let mut sched = sched;
             let bootstrap_task = ~do Task::new_root(&mut sched.stack_pool, None) || {
                 rtdebug!("boostraping a non-primary scheduler");
             };
@@ -415,16 +413,19 @@ fn run_(main: proc(), use_main_sched: bool) -> int {
     // If we do have a main thread scheduler, run it now.
 
     if use_main_sched {
-
         rtdebug!("about to create the main scheduler task");
 
         let mut main_sched = main_sched.unwrap();
 
         let home = Sched(main_sched.make_handle());
-        let mut main_task = ~Task::new_root_homed(&mut main_sched.stack_pool, None,
-                                                  home, main.take());
+        let mut main_task = ~Task::new_root_homed(&mut main_sched.stack_pool,
+                                                  None,
+                                                  home,
+                                                  ::util::replace(&mut main,
+                                                                  None).
+                                                                  unwrap());
         main_task.name = Some(SendStrStatic("<main>"));
-        main_task.death.on_exit = Some(on_exit.take());
+        main_task.death.on_exit = ::util::replace(&mut on_exit, None);
         rtdebug!("bootstrapping main_task");
 
         main_sched.bootstrap(main_task);