Skip to content

Commit 625798d

Browse files
committed
---
yaml --- r: 55130 b: refs/heads/snap-stage3 c: c1fdace h: refs/heads/master v: v3
1 parent 6f9d44a commit 625798d

File tree

5 files changed

+53
-77
lines changed

5 files changed

+53
-77
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 5f13e9ccc2e3328d4cd8ca49f84e6840dd998346
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 76ec35ae743ee299484a48b233bc64cf3779097d
4+
refs/heads/snap-stage3: c1fdace588034ae76f7ccb920ddadd9c2722a5cd
55
refs/heads/try: 8eb2bab100b42f0ba751552d8eff00eb2134c55a
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/libcore/task/mod.rs

Lines changed: 21 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ use result;
4242
use task::rt::{task_id, sched_id, rust_task};
4343
use util;
4444
use util::replace;
45+
use unstable::finally::Finally;
4546

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

@@ -591,76 +592,40 @@ pub fn get_scheduler() -> Scheduler {
591592
* ~~~
592593
*/
593594
pub unsafe fn unkillable<U>(f: &fn() -> U) -> U {
594-
struct AllowFailure {
595-
t: *rust_task,
596-
drop {
597-
unsafe {
598-
rt::rust_task_allow_kill(self.t);
599-
}
600-
}
601-
}
602-
603-
fn AllowFailure(t: *rust_task) -> AllowFailure{
604-
AllowFailure {
605-
t: t
606-
}
607-
}
608-
609595
let t = rt::rust_get_task();
610-
let _allow_failure = AllowFailure(t);
611-
rt::rust_task_inhibit_kill(t);
612-
f()
596+
do (|| {
597+
rt::rust_task_inhibit_kill(t);
598+
f()
599+
}).finally {
600+
rt::rust_task_allow_kill(t);
601+
}
613602
}
614603
615604
/// The inverse of unkillable. Only ever to be used nested in unkillable().
616605
pub unsafe fn rekillable<U>(f: &fn() -> U) -> U {
617-
struct DisallowFailure {
618-
t: *rust_task,
619-
drop {
620-
unsafe {
621-
rt::rust_task_inhibit_kill(self.t);
622-
}
623-
}
624-
}
625-
626-
fn DisallowFailure(t: *rust_task) -> DisallowFailure {
627-
DisallowFailure {
628-
t: t
629-
}
630-
}
631-
632606
let t = rt::rust_get_task();
633-
let _allow_failure = DisallowFailure(t);
634-
rt::rust_task_allow_kill(t);
635-
f()
607+
do (|| {
608+
rt::rust_task_allow_kill(t);
609+
f()
610+
}).finally {
611+
rt::rust_task_inhibit_kill(t);
612+
}
636613
}
637614
638615
/**
639616
* A stronger version of unkillable that also inhibits scheduling operations.
640617
* For use with exclusive ARCs, which use pthread mutexes directly.
641618
*/
642619
pub unsafe fn atomically<U>(f: &fn() -> U) -> U {
643-
struct DeferInterrupts {
644-
t: *rust_task,
645-
drop {
646-
unsafe {
647-
rt::rust_task_allow_yield(self.t);
648-
rt::rust_task_allow_kill(self.t);
649-
}
650-
}
651-
}
652-
653-
fn DeferInterrupts(t: *rust_task) -> DeferInterrupts {
654-
DeferInterrupts {
655-
t: t
656-
}
657-
}
658-
659620
let t = rt::rust_get_task();
660-
let _interrupts = DeferInterrupts(t);
661-
rt::rust_task_inhibit_kill(t);
662-
rt::rust_task_inhibit_yield(t);
663-
f()
621+
do (|| {
622+
rt::rust_task_inhibit_kill(t);
623+
rt::rust_task_inhibit_yield(t);
624+
f()
625+
}).finally {
626+
rt::rust_task_allow_yield(t);
627+
rt::rust_task_allow_kill(t);
628+
}
664629
}
665630
666631
#[test] #[should_fail] #[ignore(cfg(windows))]
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
// xfail-test
3+
4+
fn altsimple(any x) {
5+
match type (f) {
6+
case (int i) { print("int"); }
7+
case (str s) { print("str"); }
8+
}
9+
}
10+
11+
pub fn main() {
12+
altsimple(5);
13+
altsimple("asdfasdfsDF");
14+
}

branches/snap-stage3/src/test/run-pass/clone-with-exterior.rs

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,17 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
//xfail-test
12+
1113
extern mod std;
12-
use core::task::spawn;
1314

14-
struct Pair {
15-
a: int,
16-
b: int
15+
fn f(x : @{a:int, b:int}) {
16+
assert!((x.a == 10));
17+
assert!((x.b == 12));
1718
}
1819

1920
pub fn main() {
20-
let z = ~Pair { a : 10, b : 12};
21-
22-
let f: ~fn() = || {
23-
assert!((z.a == 10));
24-
assert!((z.b == 12));
25-
};
26-
27-
spawn(f);
21+
let z : @{a:int, b:int} = @{ a : 10, b : 12};
22+
let p = task::_spawn(bind f(z));
23+
task::join_id(p);
2824
}

branches/snap-stage3/src/test/run-pass/infinite-loops.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,16 @@
1515
// xfail-test
1616

1717
extern mod std;
18+
use task::join;
19+
20+
fn loop(n: int) {
21+
let t1: task;
22+
let t2: task;
23+
24+
if n > 0 { t1 = spawn loop(n - 1); t2 = spawn loop(n - 1); }
25+
1826

19-
fn loopy(n: int) {
20-
if n > 0 { do spawn { loopy(n - 1) }; do spawn { loopy(n - 1) }; }
2127
loop { }
2228
}
2329

24-
pub fn main() {
25-
// Commenting this out, as this will hang forever otherwise.
26-
// Even after seeing the comment above, I'm not sure what the
27-
// intention of this test is.
28-
// do spawn { loopy(5) };
29-
}
30+
pub fn main() { let t: task = spawn loop(5); join(t); }

0 commit comments

Comments
 (0)