Skip to content

Commit 8e98eab

Browse files
committed
modified local to include an implementation for try_unsafe_borrow::<Task> so that the log methods will work
1 parent 1d82fe5 commit 8e98eab

File tree

4 files changed

+17
-10
lines changed

4 files changed

+17
-10
lines changed

src/libstd/rt/io/net/tcp.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ mod test {
380380
}
381381

382382
do spawntask {
383-
for max.times {
383+
do max.times {
384384
let mut stream = TcpStream::connect(addr);
385385
stream.write([99]);
386386
}
@@ -405,7 +405,7 @@ mod test {
405405
}
406406

407407
do spawntask {
408-
for max.times {
408+
do max.times {
409409
let mut stream = TcpStream::connect(addr);
410410
stream.write([99]);
411411
}

src/libstd/rt/local.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,13 @@ impl Local for Task {
4444
}
4545
}
4646
unsafe fn unsafe_borrow() -> *mut Task { local_ptr::unsafe_borrow() }
47-
unsafe fn try_unsafe_borrow() -> Option<*mut Task> { rtabort!("unimpl task try_unsafe_borrow") }
47+
unsafe fn try_unsafe_borrow() -> Option<*mut Task> {
48+
if Local::exists::<Task>() {
49+
Some(Local::unsafe_borrow())
50+
} else {
51+
None
52+
}
53+
}
4854
}
4955

5056
impl Local for Scheduler {
@@ -95,7 +101,7 @@ impl Local for Scheduler {
95101
}
96102
}
97103
unsafe fn try_unsafe_borrow() -> Option<*mut Scheduler> {
98-
if Local::exists::<Task>() {
104+
if Local::exists::<Scheduler>() {
99105
Some(Local::unsafe_borrow())
100106
} else {
101107
None

src/libstd/rt/task.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ impl Task {
129129
death: Death::new(),
130130
destroyed: false,
131131
coroutine: Some(Coroutine::empty()),
132+
name: None,
132133
sched: None,
133134
task_type: SchedTask
134135
}

src/libstd/task/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,7 @@ fn test_spawn_unlinked_unsup_no_fail_down() { // grandchild sends on a port
685685
let ch = ch.clone();
686686
do spawn_unlinked {
687687
// Give middle task a chance to fail-but-not-kill-us.
688-
for 16.times { task::yield(); }
688+
do 16.times { task::yield(); }
689689
ch.send(()); // If killed first, grandparent hangs.
690690
}
691691
fail!(); // Shouldn't kill either (grand)parent or (grand)child.
@@ -706,7 +706,7 @@ fn test_spawn_unlinked_sup_no_fail_up() { // child unlinked fails
706706
do run_in_newsched_task {
707707
do spawn_supervised { fail!(); }
708708
// Give child a chance to fail-but-not-kill-us.
709-
for 16.times { task::yield(); }
709+
do 16.times { task::yield(); }
710710
}
711711
}
712712
#[test] #[ignore(cfg(windows))]
@@ -808,7 +808,7 @@ fn test_spawn_failure_propagate_grandchild() {
808808
do spawn_supervised {
809809
do spawn_supervised { block_forever(); }
810810
}
811-
for 16.times { task::yield(); }
811+
do 16.times { task::yield(); }
812812
fail!();
813813
};
814814
assert!(result.is_err());
@@ -824,7 +824,7 @@ fn test_spawn_failure_propagate_secondborn() {
824824
do spawn_supervised {
825825
do spawn { block_forever(); } // linked
826826
}
827-
for 16.times { task::yield(); }
827+
do 16.times { task::yield(); }
828828
fail!();
829829
};
830830
assert!(result.is_err());
@@ -840,7 +840,7 @@ fn test_spawn_failure_propagate_nephew_or_niece() {
840840
do spawn { // linked
841841
do spawn_supervised { block_forever(); }
842842
}
843-
for 16.times { task::yield(); }
843+
do 16.times { task::yield(); }
844844
fail!();
845845
};
846846
assert!(result.is_err());
@@ -856,7 +856,7 @@ fn test_spawn_linked_sup_propagate_sibling() {
856856
do spawn { // linked
857857
do spawn { block_forever(); } // linked
858858
}
859-
for 16.times { task::yield(); }
859+
do 16.times { task::yield(); }
860860
fail!();
861861
};
862862
assert!(result.is_err());

0 commit comments

Comments
 (0)