Skip to content

Commit 2dd9ea8

Browse files
committed
core: Turn task::unkillable, etc. into no-ops in newsched. rust-lang#6377
Not necessary just yet but they make ARC not work.
1 parent b51bae1 commit 2dd9ea8

File tree

3 files changed

+53
-18
lines changed

3 files changed

+53
-18
lines changed

src/libcore/rt/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ mod local_heap;
111111
pub mod logging;
112112

113113
/// Tools for testing the runtime
114-
#[cfg(test)]
115114
pub mod test;
116115

117116
/// Reference counting

src/libcore/task/mod.rs

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ use task::rt::{task_id, sched_id};
4343
use util;
4444
use util::replace;
4545
use unstable::finally::Finally;
46+
use rt::{context, OldTaskContext};
4647

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

@@ -558,23 +559,33 @@ pub fn get_scheduler() -> Scheduler {
558559
* ~~~
559560
*/
560561
pub unsafe fn unkillable<U>(f: &fn() -> U) -> U {
561-
let t = rt::rust_get_task();
562-
do (|| {
563-
rt::rust_task_inhibit_kill(t);
562+
if context() == OldTaskContext {
563+
let t = rt::rust_get_task();
564+
do (|| {
565+
rt::rust_task_inhibit_kill(t);
566+
f()
567+
}).finally {
568+
rt::rust_task_allow_kill(t);
569+
}
570+
} else {
571+
// FIXME #6377
564572
f()
565-
}).finally {
566-
rt::rust_task_allow_kill(t);
567573
}
568574
}
569575
570576
/// The inverse of unkillable. Only ever to be used nested in unkillable().
571577
pub unsafe fn rekillable<U>(f: &fn() -> U) -> U {
572-
let t = rt::rust_get_task();
573-
do (|| {
574-
rt::rust_task_allow_kill(t);
578+
if context() == OldTaskContext {
579+
let t = rt::rust_get_task();
580+
do (|| {
581+
rt::rust_task_allow_kill(t);
582+
f()
583+
}).finally {
584+
rt::rust_task_inhibit_kill(t);
585+
}
586+
} else {
587+
// FIXME #6377
575588
f()
576-
}).finally {
577-
rt::rust_task_inhibit_kill(t);
578589
}
579590
}
580591
@@ -583,14 +594,19 @@ pub unsafe fn rekillable<U>(f: &fn() -> U) -> U {
583594
* For use with exclusive ARCs, which use pthread mutexes directly.
584595
*/
585596
pub unsafe fn atomically<U>(f: &fn() -> U) -> U {
586-
let t = rt::rust_get_task();
587-
do (|| {
588-
rt::rust_task_inhibit_kill(t);
589-
rt::rust_task_inhibit_yield(t);
597+
if context() == OldTaskContext {
598+
let t = rt::rust_get_task();
599+
do (|| {
600+
rt::rust_task_inhibit_kill(t);
601+
rt::rust_task_inhibit_yield(t);
602+
f()
603+
}).finally {
604+
rt::rust_task_allow_yield(t);
605+
rt::rust_task_allow_kill(t);
606+
}
607+
} else {
608+
// FIXME #6377
590609
f()
591-
}).finally {
592-
rt::rust_task_allow_yield(t);
593-
rt::rust_task_allow_kill(t);
594610
}
595611
}
596612

src/libcore/unstable.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,4 +349,24 @@ mod tests {
349349
assert!(*one == 1);
350350
}
351351
}
352+
353+
#[test]
354+
fn newsched_shared_mutable_state() {
355+
use task::spawn;
356+
use rt::test::*;
357+
use super::*;
358+
359+
do run_in_newsched_task {
360+
unsafe {
361+
let v = shared_mutable_state(10);
362+
let vclone = clone_shared_mutable_state(&v);
363+
do spawn {
364+
unsafe {
365+
let v = get_shared_immutable_state(&vclone);
366+
assert!(*v == 10);
367+
}
368+
}
369+
}
370+
}
371+
}
352372
}

0 commit comments

Comments
 (0)