diff options
| author | Patrick Walton <pcwalton@mimiga.net> | 2013-02-25 13:23:16 -0800 |
|---|---|---|
| committer | Patrick Walton <pcwalton@mimiga.net> | 2013-02-26 04:18:12 -0800 |
| commit | e2f90091cf652218fe456ec1a54892fe1ceabb36 (patch) | |
| tree | 05fa716cc71d35bb3e288b36fa458a16785a2e3c /src/libcore/task | |
| parent | c483aab4ae391eb26dae5a17d40c148551a6c674 (diff) | |
| download | rust-e2f90091cf652218fe456ec1a54892fe1ceabb36.tar.gz rust-e2f90091cf652218fe456ec1a54892fe1ceabb36.zip | |
libcore: Move Cell to core and de-~mut core and std
Diffstat (limited to 'src/libcore/task')
| -rw-r--r-- | src/libcore/task/mod.rs | 7 | ||||
| -rw-r--r-- | src/libcore/task/spawn.rs | 9 |
2 files changed, 9 insertions, 7 deletions
diff --git a/src/libcore/task/mod.rs b/src/libcore/task/mod.rs index 336e686193b..2a640e4bf8c 100644 --- a/src/libcore/task/mod.rs +++ b/src/libcore/task/mod.rs @@ -34,6 +34,7 @@ */ use cast; +use cell::Cell; use cmp; use cmp::Eq; use iter; @@ -397,9 +398,9 @@ impl TaskBuilder { } /// Runs a task, while transfering ownership of one argument to the child. fn spawn_with<A:Owned>(arg: A, f: fn~(v: A)) { - let arg = ~mut Some(arg); - do self.spawn || { - f(option::swap_unwrap(arg)) + let arg = Cell(arg); + do self.spawn { + f(arg.take()); } } diff --git a/src/libcore/task/spawn.rs b/src/libcore/task/spawn.rs index e77af820079..5110f70ff11 100644 --- a/src/libcore/task/spawn.rs +++ b/src/libcore/task/spawn.rs @@ -73,6 +73,7 @@ #[doc(hidden)]; // FIXME #3538 use cast; +use cell::Cell; use container::Map; use option; use comm::{Chan, GenericChan, GenericPort, Port, stream}; @@ -530,11 +531,11 @@ pub fn spawn_raw(opts: TaskOpts, f: fn~()) { gen_child_taskgroup(opts.linked, opts.supervised); unsafe { - let child_data = ~mut Some((child_tg, ancestors, f)); + let child_data = Cell((child_tg, ancestors, f)); // Being killed with the unsafe task/closure pointers would leak them. do unkillable { // Agh. Get move-mode items into the closure. FIXME (#2829) - let (child_tg, ancestors, f) = option::swap_unwrap(child_data); + let (child_tg, ancestors, f) = child_data.take(); // Create child task. let new_task = match opts.sched.mode { DefaultScheduler => rt::new_task(), @@ -571,10 +572,10 @@ pub fn spawn_raw(opts: TaskOpts, f: fn~()) { ancestors: AncestorList, is_main: bool, notify_chan: Option<Chan<TaskResult>>, f: fn~()) -> fn~() { - let child_data = ~mut Some((child_arc, ancestors)); + let child_data = Cell((child_arc, ancestors)); return fn~() { // Agh. Get move-mode items into the closure. FIXME (#2829) - let mut (child_arc, ancestors) = option::swap_unwrap(child_data); + let mut (child_arc, ancestors) = child_data.take(); // Child task runs this code. // Even if the below code fails to kick the child off, we must |
