Skip to content

Commit

Permalink
core: Turn task::unkillable, etc. into no-ops in newsched. rust-lang#…
Browse files Browse the repository at this point in the history
…6377

Not necessary just yet but they make ARC not work.
  • Loading branch information
brson committed May 15, 2013
1 parent afcf4f2 commit 013b776
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 18 deletions.
1 change: 0 additions & 1 deletion src/libcore/rt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ mod local_heap;
pub mod logging;

/// Tools for testing the runtime
#[cfg(test)]
pub mod test;

/// Reference counting
Expand Down
50 changes: 33 additions & 17 deletions src/libcore/task/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ use task::rt::{task_id, sched_id};
use util;
use util::replace;
use unstable::finally::Finally;
use rt::{context, OldTaskContext};

#[cfg(test)] use comm::SharedChan;

Expand Down Expand Up @@ -558,23 +559,33 @@ pub fn get_scheduler() -> Scheduler {
* ~~~
*/
pub unsafe fn unkillable<U>(f: &fn() -> U) -> U {
let t = rt::rust_get_task();
do (|| {
rt::rust_task_inhibit_kill(t);
if context() == OldTaskContext {
let t = rt::rust_get_task();
do (|| {
rt::rust_task_inhibit_kill(t);
f()
}).finally {
rt::rust_task_allow_kill(t);
}
} else {
// FIXME #6377
f()
}).finally {
rt::rust_task_allow_kill(t);
}
}

/// The inverse of unkillable. Only ever to be used nested in unkillable().
pub unsafe fn rekillable<U>(f: &fn() -> U) -> U {
let t = rt::rust_get_task();
do (|| {
rt::rust_task_allow_kill(t);
if context() == OldTaskContext {
let t = rt::rust_get_task();
do (|| {
rt::rust_task_allow_kill(t);
f()
}).finally {
rt::rust_task_inhibit_kill(t);
}
} else {
// FIXME #6377
f()
}).finally {
rt::rust_task_inhibit_kill(t);
}
}

Expand All @@ -583,14 +594,19 @@ pub unsafe fn rekillable<U>(f: &fn() -> U) -> U {
* For use with exclusive ARCs, which use pthread mutexes directly.
*/
pub unsafe fn atomically<U>(f: &fn() -> U) -> U {
let t = rt::rust_get_task();
do (|| {
rt::rust_task_inhibit_kill(t);
rt::rust_task_inhibit_yield(t);
if context() == OldTaskContext {
let t = rt::rust_get_task();
do (|| {
rt::rust_task_inhibit_kill(t);
rt::rust_task_inhibit_yield(t);
f()
}).finally {
rt::rust_task_allow_yield(t);
rt::rust_task_allow_kill(t);
}
} else {
// FIXME #6377
f()
}).finally {
rt::rust_task_allow_yield(t);
rt::rust_task_allow_kill(t);
}
}

Expand Down

0 comments on commit 013b776

Please sign in to comment.