about summary refs log tree commit diff
path: root/src/libstd/task
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/task
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/task')
-rw-r--r--src/libstd/task/mod.rs15
-rw-r--r--src/libstd/task/spawn.rs16
2 files changed, 9 insertions, 22 deletions
diff --git a/src/libstd/task/mod.rs b/src/libstd/task/mod.rs
index a587515bb16..1777a523073 100644
--- a/src/libstd/task/mod.rs
+++ b/src/libstd/task/mod.rs
@@ -55,7 +55,6 @@
 
 use prelude::*;
 
-use cell::Cell;
 use comm::{stream, Chan, GenericChan, GenericPort, Port, Peekable};
 use result::{Result, Ok, Err};
 use rt::in_green_task_context;
@@ -284,10 +283,8 @@ impl TaskBuilder {
                 f
             }
         };
-        let prev_gen_body = Cell::new(prev_gen_body);
         let next_gen_body = {
             let f: proc(proc()) -> proc() = proc(body) {
-                let prev_gen_body = prev_gen_body.take();
                 wrapper(prev_gen_body(body))
             };
             f
@@ -548,11 +545,9 @@ struct Wrapper {
 fn test_add_wrapper() {
     let (po, ch) = stream::<()>();
     let mut b0 = task();
-    let ch = Cell::new(ch);
     do b0.add_wrapper |body| {
-        let ch = Cell::new(ch.take());
+        let ch = ch;
         let result: proc() = proc() {
-            let ch = ch.take();
             body();
             ch.send(());
         };
@@ -642,12 +637,10 @@ fn test_spawn_sched_childs_on_default_sched() {
     // Assuming tests run on the default scheduler
     let default_id = get_sched_id();
 
-    let ch = Cell::new(ch);
     do spawn_sched(SingleThreaded) {
         let parent_sched_id = get_sched_id();
-        let ch = Cell::new(ch.take());
+        let ch = ch;
         do spawn {
-            let ch = ch.take();
             let child_sched_id = get_sched_id();
             assert!(parent_sched_id != child_sched_id);
             assert_eq!(child_sched_id, default_id);
@@ -671,10 +664,10 @@ fn test_spawn_sched_blocking() {
             let (fin_po, fin_ch) = stream();
 
             let mut lock = Mutex::new();
-            let lock2 = Cell::new(lock.clone());
+            let lock2 = lock.clone();
 
             do spawn_sched(SingleThreaded) {
-                let mut lock = lock2.take();
+                let mut lock = lock2;
                 lock.lock();
 
                 start_ch.send(());
diff --git a/src/libstd/task/spawn.rs b/src/libstd/task/spawn.rs
index 153b3e4ce25..4ab7b74d300 100644
--- a/src/libstd/task/spawn.rs
+++ b/src/libstd/task/spawn.rs
@@ -77,7 +77,6 @@
 
 use prelude::*;
 
-use cell::Cell;
 use comm::{GenericChan, oneshot};
 use rt::local::Local;
 use rt::sched::{Scheduler, Shutdown, TaskFromFriend};
@@ -134,23 +133,19 @@ pub fn spawn_raw(mut opts: TaskOpts, f: proc()) {
             // Create a task that will later be used to join with the new scheduler
             // thread when it is ready to terminate
             let (thread_port, thread_chan) = oneshot();
-            let thread_port_cell = Cell::new(thread_port);
             let join_task = do Task::build_child(None) {
                 debug!("running join task");
-                let thread_port = thread_port_cell.take();
                 let thread: Thread<()> = thread_port.recv();
                 thread.join();
             };
 
             // Put the scheduler into another thread
-            let new_sched_cell = Cell::new(new_sched);
-            let orig_sched_handle_cell = Cell::new((*sched).make_handle());
-            let join_task_cell = Cell::new(join_task);
+            let orig_sched_handle = (*sched).make_handle();
 
+            let new_sched = new_sched;
             let thread = do Thread::start {
-                let mut new_sched = new_sched_cell.take();
-                let mut orig_sched_handle = orig_sched_handle_cell.take();
-                let join_task = join_task_cell.take();
+                let mut new_sched = new_sched;
+                let mut orig_sched_handle = orig_sched_handle;
 
                 let bootstrap_task = ~do Task::new_root(&mut new_sched.stack_pool, None) || {
                     debug!("boostrapping a 1:1 scheduler");
@@ -178,9 +173,8 @@ pub fn spawn_raw(mut opts: TaskOpts, f: proc()) {
 
     if opts.notify_chan.is_some() {
         let notify_chan = opts.notify_chan.take_unwrap();
-        let notify_chan = Cell::new(notify_chan);
         let on_exit: proc(UnwindResult) = proc(task_result) {
-            notify_chan.take().send(task_result)
+            notify_chan.send(task_result)
         };
         task.death.on_exit = Some(on_exit);
     }