aboutsummaryrefslogtreecommitdiff
path: root/src/rt/rust_upcall.cpp
diff options
context:
space:
mode:
authorMichael Bebenita <[email protected]>2010-07-28 16:24:50 -0700
committerGraydon Hoare <[email protected]>2010-07-28 20:30:29 -0700
commit4ff8e15128f90d4e9e57897c48280c6f82bb8343 (patch)
tree86c3808e729b4f596c3c23e228738d3d25b108bc /src/rt/rust_upcall.cpp
parentRename rust_proxy_delegate to maybe_proxy, flesh out logic in it. Add strong-... (diff)
downloadrust-4ff8e15128f90d4e9e57897c48280c6f82bb8343.tar.xz
rust-4ff8e15128f90d4e9e57897c48280c6f82bb8343.zip
Move notification-messages out into their own file and unify into notify_message, make them use proxies, cache task proxies in dom.
Diffstat (limited to 'src/rt/rust_upcall.cpp')
-rw-r--r--src/rt/rust_upcall.cpp46
1 files changed, 25 insertions, 21 deletions
diff --git a/src/rt/rust_upcall.cpp b/src/rt/rust_upcall.cpp
index e4604049..42203bec 100644
--- a/src/rt/rust_upcall.cpp
+++ b/src/rt/rust_upcall.cpp
@@ -122,19 +122,25 @@ extern "C" CDECL void upcall_yield(rust_task *task) {
}
extern "C" CDECL void
-upcall_join(rust_task *task, maybe_proxy<rust_task> *proxy) {
+upcall_join(rust_task *task, maybe_proxy<rust_task> *target) {
LOG_UPCALL_ENTRY(task);
task->log(rust_log::UPCALL | rust_log::COMM,
- "join proxy 0x%" PRIxPTR " -> task = 0x%" PRIxPTR,
- proxy, proxy->delegate());
-
- rust_task *other = proxy->delegate();
-
- // If the other task is already dying, we don't have to wait for it.
- if (!other->dead()) {
- other->waiting_tasks.push(&task->alarm);
- task->block(other);
+ "target: 0x%" PRIxPTR ", task: 0x%" PRIxPTR,
+ target, target->delegate());
+
+ rust_task *target_task = target->delegate();
+ if (target->is_proxy()) {
+ notify_message::
+ send(notify_message::JOIN, "join", task, target->as_proxy());
+ task->block(target_task);
task->yield(2);
+ } else {
+ // If the other task is already dying, we don't have to wait for it.
+ if (target_task->dead() == false) {
+ target_task->tasks_waiting_to_join.push(task);
+ task->block(target_task);
+ task->yield(2);
+ }
}
}
@@ -194,22 +200,20 @@ extern "C" CDECL void upcall_fail(rust_task *task, char const *expr,
* Called whenever a task's ref count drops to zero.
*/
extern "C" CDECL void
-upcall_kill(rust_task *task, maybe_proxy<rust_task> *target_proxy) {
+upcall_kill(rust_task *task, maybe_proxy<rust_task> *target) {
LOG_UPCALL_ENTRY(task);
- rust_task *target_task = target_proxy->delegate();
- if (target_proxy != target_task) {
- task->dom->free(target_proxy);
- }
+ rust_task *target_task = target->delegate();
+
task->log(rust_log::UPCALL | rust_log::TASK,
"kill task 0x%" PRIxPTR ", ref count %d",
target_task,
target_task->ref_count);
- if (requires_message_passing(task, target_task)) {
- rust_dom *target_domain = target_task->dom;
- target_domain->send_message(
- new (target_domain)
- kill_task_message(target_domain, target_task));
+ if (target->is_proxy()) {
+ notify_message::
+ send(notify_message::KILL, "kill", task, target->as_proxy());
+ // The proxy ref_count dropped to zero, delete it here.
+ delete target->as_proxy();
} else {
target_task->kill();
}
@@ -224,7 +228,7 @@ upcall_exit(rust_task *task) {
task->log(rust_log::UPCALL | rust_log::TASK,
"task ref_count: %d", task->ref_count);
task->die();
- task->notify_waiting_tasks();
+ task->notify_tasks_waiting_to_join();
task->yield(1);
}