about summary refs log tree commit diff
path: root/src/rt/rust_task.cpp
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2011-11-13 16:36:47 -0800
committerBrian Anderson <banderson@mozilla.com>2011-11-13 16:36:47 -0800
commit58e923de6ef89f252f350d0d89f7b13798b517bd (patch)
tree4e68c04e3acd27844ff348d7472c2f67264f6370 /src/rt/rust_task.cpp
parent138d9ca5d536a67465f8b97bee12a0c24b9e3233 (diff)
downloadrust-58e923de6ef89f252f350d0d89f7b13798b517bd.tar.gz
rust-58e923de6ef89f252f350d0d89f7b13798b517bd.zip
rt: Perform task notification before killing the parent task
Diffstat (limited to 'src/rt/rust_task.cpp')
-rw-r--r--src/rt/rust_task.cpp42
1 files changed, 24 insertions, 18 deletions
diff --git a/src/rt/rust_task.cpp b/src/rt/rust_task.cpp
index e5d43e7b308..b2158945182 100644
--- a/src/rt/rust_task.cpp
+++ b/src/rt/rust_task.cpp
@@ -126,24 +126,6 @@ rust_task::~rust_task()
     DLOG(sched, task, "~rust_task %s @0x%" PRIxPTR ", refcnt=%d",
          name, (uintptr_t)this, ref_count);
 
-    if(user.notify_enabled) {
-        rust_task *target_task = kernel->get_task_by_id(user.notify_chan.task);
-        if (target_task) {
-            rust_port *target_port =
-                target_task->get_port_by_id(user.notify_chan.port);
-            if(target_port) {
-                task_notification msg;
-                msg.id = user.id;
-                msg.result = failed ? tr_failure : tr_success;
-
-                target_port->send(&msg);
-                scoped_lock with(target_task->lock);
-                target_port->deref();
-            }
-            target_task->deref();
-        }
-    }
-
     if (supervisor) {
         supervisor->deref();
     }
@@ -203,6 +185,8 @@ void task_start_wrapper(spawn_args *a)
         failed = true;
     }
 
+    task->notify(!failed);
+
     if (failed) {
 #ifndef __WIN32__
         task->conclude_failure();
@@ -605,6 +589,28 @@ rust_task::claim_alloc(void *alloc, const type_desc *tydesc) {
     lock.unlock();
 }
 
+void
+rust_task::notify(bool success) {
+    // FIXME (1078) Do this in rust code
+    if(user.notify_enabled) {
+        rust_task *target_task = kernel->get_task_by_id(user.notify_chan.task);
+        if (target_task) {
+            rust_port *target_port =
+                target_task->get_port_by_id(user.notify_chan.port);
+            if(target_port) {
+                task_notification msg;
+                msg.id = user.id;
+                msg.result = !success ? tr_failure : tr_success;
+
+                target_port->send(&msg);
+                scoped_lock with(target_task->lock);
+                target_port->deref();
+            }
+            target_task->deref();
+        }
+    }
+}
+
 //
 // Local Variables:
 // mode: C++