Skip to content

Commit

Permalink
modified local to include an implementation for try_unsafe_borrow::<T…
Browse files Browse the repository at this point in the history
…ask> so that the log methods will work
  • Loading branch information
toddaaro committed Aug 1, 2013
1 parent 1d82fe5 commit 8e98eab
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/libstd/rt/io/net/tcp.rs
Expand Up @@ -380,7 +380,7 @@ mod test {
}

do spawntask {
for max.times {
do max.times {
let mut stream = TcpStream::connect(addr);
stream.write([99]);
}
Expand All @@ -405,7 +405,7 @@ mod test {
}

do spawntask {
for max.times {
do max.times {
let mut stream = TcpStream::connect(addr);
stream.write([99]);
}
Expand Down
10 changes: 8 additions & 2 deletions src/libstd/rt/local.rs
Expand Up @@ -44,7 +44,13 @@ impl Local for Task {
}
}
unsafe fn unsafe_borrow() -> *mut Task { local_ptr::unsafe_borrow() }
unsafe fn try_unsafe_borrow() -> Option<*mut Task> { rtabort!("unimpl task try_unsafe_borrow") }
unsafe fn try_unsafe_borrow() -> Option<*mut Task> {
if Local::exists::<Task>() {
Some(Local::unsafe_borrow())
} else {
None
}
}
}

impl Local for Scheduler {
Expand Down Expand Up @@ -95,7 +101,7 @@ impl Local for Scheduler {
}
}
unsafe fn try_unsafe_borrow() -> Option<*mut Scheduler> {
if Local::exists::<Task>() {
if Local::exists::<Scheduler>() {
Some(Local::unsafe_borrow())
} else {
None
Expand Down
1 change: 1 addition & 0 deletions src/libstd/rt/task.rs
Expand Up @@ -129,6 +129,7 @@ impl Task {
death: Death::new(),
destroyed: false,
coroutine: Some(Coroutine::empty()),
name: None,
sched: None,
task_type: SchedTask
}
Expand Down
12 changes: 6 additions & 6 deletions src/libstd/task/mod.rs
Expand Up @@ -685,7 +685,7 @@ fn test_spawn_unlinked_unsup_no_fail_down() { // grandchild sends on a port
let ch = ch.clone();
do spawn_unlinked {
// Give middle task a chance to fail-but-not-kill-us.
for 16.times { task::yield(); }
do 16.times { task::yield(); }
ch.send(()); // If killed first, grandparent hangs.
}
fail!(); // Shouldn't kill either (grand)parent or (grand)child.
Expand All @@ -706,7 +706,7 @@ fn test_spawn_unlinked_sup_no_fail_up() { // child unlinked fails
do run_in_newsched_task {
do spawn_supervised { fail!(); }
// Give child a chance to fail-but-not-kill-us.
for 16.times { task::yield(); }
do 16.times { task::yield(); }
}
}
#[test] #[ignore(cfg(windows))]
Expand Down Expand Up @@ -808,7 +808,7 @@ fn test_spawn_failure_propagate_grandchild() {
do spawn_supervised {
do spawn_supervised { block_forever(); }
}
for 16.times { task::yield(); }
do 16.times { task::yield(); }
fail!();
};
assert!(result.is_err());
Expand All @@ -824,7 +824,7 @@ fn test_spawn_failure_propagate_secondborn() {
do spawn_supervised {
do spawn { block_forever(); } // linked
}
for 16.times { task::yield(); }
do 16.times { task::yield(); }
fail!();
};
assert!(result.is_err());
Expand All @@ -840,7 +840,7 @@ fn test_spawn_failure_propagate_nephew_or_niece() {
do spawn { // linked
do spawn_supervised { block_forever(); }
}
for 16.times { task::yield(); }
do 16.times { task::yield(); }
fail!();
};
assert!(result.is_err());
Expand All @@ -856,7 +856,7 @@ fn test_spawn_linked_sup_propagate_sibling() {
do spawn { // linked
do spawn { block_forever(); } // linked
}
for 16.times { task::yield(); }
do 16.times { task::yield(); }
fail!();
};
assert!(result.is_err());
Expand Down

0 comments on commit 8e98eab

Please sign in to comment.