Skip to content

Commit 470565e

Browse files
author
Eric Holk
committed
---
yaml --- r: 3139 b: refs/heads/master c: c4f9bd9 h: refs/heads/master i: 3137: 65335df 3135: 9f7c8cf v: v3
1 parent ec02af3 commit 470565e

File tree

5 files changed

+27
-6
lines changed

5 files changed

+27
-6
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 1fa9133b76ec4641e5470cbea8a8f95ec32f9563
2+
refs/heads/master: c4f9bd94700188678893659580f3b7aa80da3b7d

trunk/src/lib/task.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
native "rust" mod rustrt {
22
fn task_sleep(uint time_in_us);
33
fn task_yield();
4+
fn task_join(task t);
45
}
56

67
/**
@@ -17,8 +18,7 @@ fn yield() {
1718
}
1819

1920
fn join(task t) {
20-
// TODO: figure out how to pass tasks to the runtime and call the builtin
21-
// join.
21+
ret rustrt::task_join(t);
2222
}
2323

2424
// Local Variables:

trunk/src/rt/rust_builtin.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,12 @@ task_yield(rust_task *task) {
361361

362362
extern "C" CDECL void
363363
task_join(rust_task *task, rust_task *join_task) {
364-
// TODO
364+
// If the other task is already dying, we don't have to wait for it.
365+
if (join_task->dead() == false) {
366+
join_task->tasks_waiting_to_join.push(task);
367+
task->block(join_task, "joining local task");
368+
task->yield(2);
369+
}
365370
}
366371

367372
/* Debug builtins for std.dbg. */

trunk/src/rt/rust_upcall.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -509,8 +509,6 @@ upcall_new_task(rust_task *spawner, rust_vec *name) {
509509
return task;
510510
}
511511

512-
// TODO: This is copied from rust_task.cpp. Both copies should be moved to a
513-
// common location.
514512
static uintptr_t
515513
align_down(uintptr_t sp)
516514
{

trunk/src/test/run-pass/join.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// xfail-stage0
2+
// -*- rust -*-
3+
4+
use std;
5+
6+
import std::task::*;
7+
8+
fn main() {
9+
auto other = spawn child();
10+
log_err "1";
11+
yield();
12+
join(other);
13+
log_err "3";
14+
}
15+
16+
fn child() {
17+
log_err "2";
18+
}

0 commit comments

Comments
 (0)