about summary refs log tree commit diff
path: root/src/libstd/task
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2013-07-02 17:36:58 -0700
committerBrian Anderson <banderson@mozilla.com>2013-07-03 14:49:13 -0700
commit1098d6980b13dc00e3f20deae987423e3bcae9ce (patch)
tree4d6cfd62f1d0d3298d4144aebd6c81c91edea9dc /src/libstd/task
parentf8a4d09f7efb618ca3f8b70374e158504cb33cb0 (diff)
parentab34864a304fa364dc91bf16988e272e93de8d62 (diff)
downloadrust-1098d6980b13dc00e3f20deae987423e3bcae9ce.tar.gz
rust-1098d6980b13dc00e3f20deae987423e3bcae9ce.zip
Merge remote-tracking branch 'mozilla/master'
Conflicts:
	src/libextra/test.rs
	src/libstd/at_vec.rs
	src/libstd/cleanup.rs
	src/libstd/rt/comm.rs
	src/libstd/rt/global_heap.rs
	src/libstd/task/spawn.rs
	src/libstd/unstable/lang.rs
	src/libstd/vec.rs
	src/rt/rustrt.def.in
	src/test/run-pass/extern-pub.rs
Diffstat (limited to 'src/libstd/task')
-rw-r--r--src/libstd/task/local_data_priv.rs4
-rw-r--r--src/libstd/task/mod.rs22
-rw-r--r--src/libstd/task/spawn.rs22
3 files changed, 24 insertions, 24 deletions
diff --git a/src/libstd/task/local_data_priv.rs b/src/libstd/task/local_data_priv.rs
index f6b14a51539..0956b76c970 100644
--- a/src/libstd/task/local_data_priv.rs
+++ b/src/libstd/task/local_data_priv.rs
@@ -142,7 +142,7 @@ unsafe fn local_data_lookup<T: 'static>(
     -> Option<(uint, *libc::c_void)> {
 
     let key_value = key_to_key_value(key);
-    let map_pos = (*map).position(|entry|
+    let map_pos = (*map).iter().position_(|entry|
         match *entry {
             Some((k,_,_)) => k == key_value,
             None => false
@@ -215,7 +215,7 @@ pub unsafe fn local_set<T: 'static>(
         }
         None => {
             // Find an empty slot. If not, grow the vector.
-            match (*map).position(|x| x.is_none()) {
+            match (*map).iter().position_(|x| x.is_none()) {
                 Some(empty_index) => { map[empty_index] = new_entry; }
                 None => { map.push(new_entry); }
             }
diff --git a/src/libstd/task/mod.rs b/src/libstd/task/mod.rs
index b0fc6b2884f..ae8f1c2101d 100644
--- a/src/libstd/task/mod.rs
+++ b/src/libstd/task/mod.rs
@@ -353,7 +353,7 @@ impl TaskBuilder {
     }
 
     /// Runs a task, while transfering ownership of one argument to the child.
-    pub fn spawn_with<A:Owned>(&mut self, arg: A, f: ~fn(v: A)) {
+    pub fn spawn_with<A:Send>(&mut self, arg: A, f: ~fn(v: A)) {
         let arg = Cell::new(arg);
         do self.spawn {
             f(arg.take());
@@ -373,7 +373,7 @@ impl TaskBuilder {
      * # Failure
      * Fails if a future_result was already set for this task.
      */
-    pub fn try<T:Owned>(&mut self, f: ~fn() -> T) -> Result<T,()> {
+    pub fn try<T:Send>(&mut self, f: ~fn() -> T) -> Result<T,()> {
         let (po, ch) = stream::<T>();
         let mut result = None;
 
@@ -445,7 +445,7 @@ pub fn spawn_supervised(f: ~fn()) {
     task.spawn(f)
 }
 
-pub fn spawn_with<A:Owned>(arg: A, f: ~fn(v: A)) {
+pub fn spawn_with<A:Send>(arg: A, f: ~fn(v: A)) {
     /*!
      * Runs a task, while transfering ownership of one argument to the
      * child.
@@ -478,7 +478,7 @@ pub fn spawn_sched(mode: SchedMode, f: ~fn()) {
     task.spawn(f)
 }
 
-pub fn try<T:Owned>(f: ~fn() -> T) -> Result<T,()> {
+pub fn try<T:Send>(f: ~fn() -> T) -> Result<T,()> {
     /*!
      * Execute a function in another task and return either the return value
      * of the function or result::err.
@@ -923,17 +923,15 @@ fn test_spawn_sched_blocking() {
             let lock = testrt::rust_dbg_lock_create();
 
             do spawn_sched(SingleThreaded) {
-                unsafe {
-                    testrt::rust_dbg_lock_lock(lock);
+                testrt::rust_dbg_lock_lock(lock);
 
-                    start_ch.send(());
+                start_ch.send(());
 
-                    // Block the scheduler thread
-                    testrt::rust_dbg_lock_wait(lock);
-                    testrt::rust_dbg_lock_unlock(lock);
+                // Block the scheduler thread
+                testrt::rust_dbg_lock_wait(lock);
+                testrt::rust_dbg_lock_unlock(lock);
 
-                    fin_ch.send(());
-                }
+                fin_ch.send(());
             };
 
             // Wait until the other task has its lock
diff --git a/src/libstd/task/spawn.rs b/src/libstd/task/spawn.rs
index aea8cda6a21..bcb7e06bf1f 100644
--- a/src/libstd/task/spawn.rs
+++ b/src/libstd/task/spawn.rs
@@ -91,8 +91,8 @@ use uint;
 use util;
 use unstable::sync::{Exclusive, exclusive};
 use rt::local::Local;
-use iterator::{IteratorUtil};
 use rt::task::Task;
+use iterator::IteratorUtil;
 
 #[cfg(test)] use task::default_task_opts;
 #[cfg(test)] use comm;
@@ -112,7 +112,7 @@ fn taskset_remove(tasks: &mut TaskSet, task: *rust_task) {
     assert!(was_present);
 }
 pub fn taskset_each(tasks: &TaskSet, blk: &fn(v: *rust_task) -> bool) -> bool {
-    tasks.each(|k| blk(*k))
+    tasks.iter().advance(|k| blk(*k))
 }
 
 // One of these per group of linked-failure tasks.
@@ -130,7 +130,7 @@ type TaskGroupInner<'self> = &'self mut Option<TaskGroupData>;
 
 // A taskgroup is 'dead' when nothing can cause it to fail; only members can.
 fn taskgroup_is_dead(tg: &TaskGroupData) -> bool {
-    (&const tg.members).is_empty()
+    tg.members.is_empty()
 }
 
 // A list-like structure by which taskgroups keep track of all ancestor groups
@@ -231,11 +231,15 @@ fn each_ancestor(list:        &mut AncestorList,
         // 'do_continue'  - Did the forward_blk succeed at this point? (i.e.,
         //                  should we recurse? or should our callers unwind?)
 
+        let forward_blk = Cell::new(forward_blk);
+
         // The map defaults to None, because if ancestors is None, we're at
         // the end of the list, which doesn't make sense to coalesce.
         return do (**ancestors).map_default((None,false)) |ancestor_arc| {
             // NB: Takes a lock! (this ancestor node)
             do access_ancestors(ancestor_arc) |nobe| {
+                // Argh, but we couldn't give it to coalesce() otherwise.
+                let forward_blk = forward_blk.take();
                 // Check monotonicity
                 assert!(last_generation > nobe.generation);
                 /*##########################################################*
@@ -318,7 +322,7 @@ struct TCB {
 
 impl Drop for TCB {
     // Runs on task exit.
-    fn finalize(&self) {
+    fn drop(&self) {
         unsafe {
             // FIXME(#4330) Need self by value to get mutability.
             let this: &mut TCB = transmute(self);
@@ -373,7 +377,7 @@ struct AutoNotify {
 }
 
 impl Drop for AutoNotify {
-    fn finalize(&self) {
+    fn drop(&self) {
         let result = if self.failed { Failure } else { Success };
         self.notify_chan.send(result);
     }
@@ -610,11 +614,8 @@ fn spawn_raw_newsched(mut opts: TaskOpts, f: ~fn()) {
 
     rtdebug!("spawn about to take scheduler");
 
-    let mut sched = Local::take::<Scheduler>();
+    let sched = Local::take::<Scheduler>();
     rtdebug!("took sched in spawn");
-//    let task = ~Coroutine::with_task(&mut sched.stack_pool,
-//                                     task, f);
-//    let task = ~Task::new_root(&mut sched.stack_pool, f);
     sched.schedule_task(task);
 }
 
@@ -669,7 +670,8 @@ fn spawn_raw_oldsched(mut opts: TaskOpts, f: ~fn()) {
         let child_data = Cell::new((notify_chan, child_arc, ancestors));
         let result: ~fn() = || {
             // Agh. Get move-mode items into the closure. FIXME (#2829)
-            let mut (notify_chan, child_arc, ancestors) = child_data.take();
+            let (notify_chan, child_arc, ancestors) = child_data.take();
+            let mut ancestors = ancestors;
             // Child task runs this code.
 
             // Even if the below code fails to kick the child off, we must