aboutsummaryrefslogtreecommitdiff
path: root/src/rt/rust_dom.cpp
diff options
context:
space:
mode:
authorMichael Bebenita <[email protected]>2010-07-28 16:46:13 -0700
committerGraydon Hoare <[email protected]>2010-07-28 20:30:29 -0700
commit4246d567b7a999155524669e3b0419e8f71080b1 (patch)
tree38ab4d3aa04b25e37db9e663890235edf2f3a8a6 /src/rt/rust_dom.cpp
parentMove notification-messages out into their own file and unify into notify_mess... (diff)
downloadrust-4246d567b7a999155524669e3b0419e8f71080b1.tar.xz
rust-4246d567b7a999155524669e3b0419e8f71080b1.zip
Move ports out into their own file, add data_message and make communication system use it (and proxies) instead of existing token scheme.
Diffstat (limited to 'src/rt/rust_dom.cpp')
-rw-r--r--src/rt/rust_dom.cpp31
1 files changed, 30 insertions, 1 deletions
diff --git a/src/rt/rust_dom.cpp b/src/rt/rust_dom.cpp
index 4d1917f4..0c175e78 100644
--- a/src/rt/rust_dom.cpp
+++ b/src/rt/rust_dom.cpp
@@ -46,6 +46,14 @@ rust_dom::delete_proxies() {
" in dom %" PRIxPTR, task_proxy, task_proxy->dom);
delete task_proxy;
}
+
+ rust_port *port;
+ rust_proxy<rust_port> *port_proxy;
+ while (_port_proxies.pop(&port, &port_proxy)) {
+ log(rust_log::TASK, "deleting proxy %" PRIxPTR
+ " in dom %" PRIxPTR, port_proxy, port_proxy->dom);
+ delete port_proxy;
+ }
}
rust_dom::~rust_dom() {
@@ -217,7 +225,6 @@ rust_dom::reap_dead_tasks() {
for (size_t i = 0; i < dead_tasks.length(); ) {
rust_task *task = dead_tasks[i];
if (task->ref_count == 0) {
- I(this, !task->waiting_tasks.length());
I(this, task->tasks_waiting_to_join.is_empty());
dead_tasks.swap_delete(task);
@@ -270,6 +277,28 @@ rust_dom::get_task_proxy(rust_task *task) {
_task_proxies.put(task, proxy);
return proxy;
}
+
+/**
+ * Gets a proxy for this port.
+ *
+ * TODO: This method needs to be synchronized since it's usually called
+ * during upcall_clone_chan in a different thread. However, for now
+ * since this usually happens before the thread actually starts,
+ * we may get lucky without synchronizing.
+ *
+ */
+rust_proxy<rust_port> *
+rust_dom::get_port_proxy_synchronized(rust_port *port) {
+ rust_proxy<rust_port> *proxy = NULL;
+ if (_port_proxies.get(port, &proxy)) {
+ return proxy;
+ }
+ log(rust_log::COMM, "no proxy for 0x%" PRIxPTR, port);
+ proxy = new (this) rust_proxy<rust_port> (this, port, false);
+ _port_proxies.put(port, proxy);
+ return proxy;
+}
+
/**
* Schedules a running task for execution. Only running tasks can be
* activated. Blocked tasks have to be unblocked before they can be