about summary refs log tree commit diff
path: root/src/rt
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2011-07-14 19:39:53 -0700
committerBrian Anderson <banderson@mozilla.com>2011-07-15 10:07:29 -0700
commitced8393f203fc661df7a5a0159a5edfd826eef12 (patch)
treeefc98dacc8ec300c63b2e3af1c7dd78f7f4bac5a /src/rt
parentd9cc4cb81b91e5d1735ef6c14e181e41247c9314 (diff)
downloadrust-ced8393f203fc661df7a5a0159a5edfd826eef12.tar.gz
rust-ced8393f203fc661df7a5a0159a5edfd826eef12.zip
Modify task::join to indicate how the task terminated
This involves sticking yet another field into the task structure
Diffstat (limited to 'src/rt')
-rw-r--r--src/rt/rust_builtin.cpp7
-rw-r--r--src/rt/rust_task.cpp4
-rw-r--r--src/rt/rust_task.h3
3 files changed, 12 insertions, 2 deletions
diff --git a/src/rt/rust_builtin.cpp b/src/rt/rust_builtin.cpp
index e8900dd730a..bdabbb1ed37 100644
--- a/src/rt/rust_builtin.cpp
+++ b/src/rt/rust_builtin.cpp
@@ -410,7 +410,7 @@ task_yield(rust_task *task) {
     task->yield(1);
 }
 
-extern "C" CDECL void
+extern "C" CDECL intptr_t
 task_join(rust_task *task, rust_task *join_task) {
     // If the other task is already dying, we don't have to wait for it.
     join_task->lock.lock();
@@ -423,6 +423,11 @@ task_join(rust_task *task, rust_task *join_task) {
     else {
         join_task->lock.unlock();
     }
+    if (!join_task->failed) {
+        return 0;
+    } else {
+        return -1;
+    }
 }
 
 extern "C" CDECL void
diff --git a/src/rt/rust_task.cpp b/src/rt/rust_task.cpp
index fd9a2cc862c..d56cb8b6276 100644
--- a/src/rt/rust_task.cpp
+++ b/src/rt/rust_task.cpp
@@ -82,7 +82,8 @@ rust_task::rust_task(rust_scheduler *sched, rust_task_list *state,
     running_on(-1),
     pinned_on(-1),
     local_region(&sched->srv->local_region),
-    _on_wakeup(NULL)
+    _on_wakeup(NULL),
+    failed(false)
 {
     LOGPTR(sched, "new task", (uintptr_t)this);
     DLOG(sched, task, "sizeof(task) = %d (0x%x)", sizeof *this, sizeof *this);
@@ -230,6 +231,7 @@ rust_task::fail() {
     // FIXME: implement unwinding again.
     if (this == sched->root_task)
         sched->fail();
+    failed = true;
 }
 
 void
diff --git a/src/rt/rust_task.h b/src/rt/rust_task.h
index 0babf4ab7e7..17d1a9838a7 100644
--- a/src/rt/rust_task.h
+++ b/src/rt/rust_task.h
@@ -89,6 +89,9 @@ rust_task : public maybe_proxy<rust_task>,
 
     wakeup_callback *_on_wakeup;
 
+    // Indicates that the task ended in failure
+    bool failed;
+
     lock_and_signal lock;
 
     // Only a pointer to 'name' is kept, so it must live as long as this task.