about summary refs log tree commit diff
path: root/src/libstd/task
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2013-07-30 18:58:17 -0700
committerbors <bors@rust-lang.org>2013-07-30 18:58:17 -0700
commit5633a5363b6c650500b8b6496ddd49ea8c698f92 (patch)
treee0a6b69c6eb47b0bba56a452738de000ba5cab2e /src/libstd/task
parent6534b4d4ce87940954b017bd27dc4e5fa7e59703 (diff)
parent6b75e92afe174696bd00eaa8283ad9e3b1d01582 (diff)
downloadrust-5633a5363b6c650500b8b6496ddd49ea8c698f92.tar.gz
rust-5633a5363b6c650500b8b6496ddd49ea8c698f92.zip
auto merge of #8008 : bblum/rust/select, r=brson
Main logic in ```Implement select() for new runtime pipes.```. The guts of the ```PortOne::try_recv()``` implementation are now split up across several functions, ```optimistic_check```, ```block_on```, and ```recv_ready```.

There is one weird FIXME I left open here, in the "implement select" commit -- an assertion I couldn't get to work in the receive path, on an invariant that for some reason doesn't hold with ```SharedPort```. Still investigating this.
Diffstat (limited to 'src/libstd/task')
-rw-r--r--src/libstd/task/mod.rs44
-rw-r--r--src/libstd/task/spawn.rs11
2 files changed, 31 insertions, 24 deletions
diff --git a/src/libstd/task/mod.rs b/src/libstd/task/mod.rs
index df927cb6a7a..c26349b220d 100644
--- a/src/libstd/task/mod.rs
+++ b/src/libstd/task/mod.rs
@@ -618,32 +618,34 @@ pub fn get_scheduler() -> Scheduler {
  * }
  * ~~~
  */
-pub unsafe fn unkillable<U>(f: &fn() -> U) -> U {
+pub fn unkillable<U>(f: &fn() -> U) -> U {
     use rt::task::Task;
 
-    match context() {
-        OldTaskContext => {
-            let t = rt::rust_get_task();
-            do (|| {
-                rt::rust_task_inhibit_kill(t);
-                f()
-            }).finally {
-                rt::rust_task_allow_kill(t);
+    unsafe {
+        match context() {
+            OldTaskContext => {
+                let t = rt::rust_get_task();
+                do (|| {
+                    rt::rust_task_inhibit_kill(t);
+                    f()
+                }).finally {
+                    rt::rust_task_allow_kill(t);
+                }
             }
-        }
-        TaskContext => {
-            // The inhibits/allows might fail and need to borrow the task.
-            let t = Local::unsafe_borrow::<Task>();
-            do (|| {
-                (*t).death.inhibit_kill((*t).unwinder.unwinding);
-                f()
-            }).finally {
-                (*t).death.allow_kill((*t).unwinder.unwinding);
+            TaskContext => {
+                // The inhibits/allows might fail and need to borrow the task.
+                let t = Local::unsafe_borrow::<Task>();
+                do (|| {
+                    (*t).death.inhibit_kill((*t).unwinder.unwinding);
+                    f()
+                }).finally {
+                    (*t).death.allow_kill((*t).unwinder.unwinding);
+                }
             }
+            // FIXME(#3095): This should be an rtabort as soon as the scheduler
+            // no longer uses a workqueue implemented with an Exclusive.
+            _ => f()
         }
-        // FIXME(#3095): This should be an rtabort as soon as the scheduler
-        // no longer uses a workqueue implemented with an Exclusive.
-        _ => f()
     }
 }
 
diff --git a/src/libstd/task/spawn.rs b/src/libstd/task/spawn.rs
index 61dcc33c629..749db307012 100644
--- a/src/libstd/task/spawn.rs
+++ b/src/libstd/task/spawn.rs
@@ -512,7 +512,9 @@ impl RuntimeGlue {
     unsafe fn kill_all_tasks(task: &TaskHandle) {
         match *task {
             OldTask(ptr) => rt::rust_task_kill_all(ptr),
-            NewTask(ref _handle) => rtabort!("unimplemented"), // FIXME(#7544)
+            // FIXME(#7544): Remove the kill_all feature entirely once the
+            // oldsched goes away.
+            NewTask(ref _handle) => rtabort!("can't kill_all in newsched"),
         }
     }
 
@@ -573,7 +575,10 @@ impl RuntimeGlue {
                             members: members,
                             descendants: TaskSet::new(),
                         }));
-                        let group = Taskgroup(tasks, AncestorList(None), true, None);
+                        // FIXME(#7544): Remove the is_main flag entirely once
+                        // the newsched goes away. The main taskgroup has no special
+                        // behaviour.
+                        let group = Taskgroup(tasks, AncestorList(None), false, None);
                         (*me).taskgroup = Some(group);
                         (*me).taskgroup.get_ref()
                     }
@@ -689,7 +694,7 @@ fn spawn_raw_newsched(mut opts: TaskOpts, f: ~fn()) {
         // Should be run after the local-borrowed task is returned.
         if enlist_success {
             if indestructible {
-                unsafe { do unkillable { f() } }
+                do unkillable { f() }
             } else {
                 f()
             }