about summary refs log tree commit diff
path: root/src/rt/rust_chan.cpp
diff options
context:
space:
mode:
authorEric Holk <eholk@mozilla.com>2011-06-22 15:44:47 -0700
committerGraydon Hoare <graydon@mozilla.com>2011-06-27 09:58:39 -0700
commit681c063ec02ce9fc6bdcd99b0b73f016a9839d59 (patch)
tree24f775ba4dda57790e7c8ecb5cf9abdfc4209ee8 /src/rt/rust_chan.cpp
parent6367bcf4276c06d41b0d66f10711ca3b076ae547 (diff)
downloadrust-681c063ec02ce9fc6bdcd99b0b73f016a9839d59.tar.gz
rust-681c063ec02ce9fc6bdcd99b0b73f016a9839d59.zip
Conservatively serialize nearly all upcalls. Successfuly ran make check with RUST_THREADS=8, so we're probably fairly safe now. In the future we can relax the synchronization to get better performance.
Diffstat (limited to 'src/rt/rust_chan.cpp')
-rw-r--r--src/rt/rust_chan.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/rt/rust_chan.cpp b/src/rt/rust_chan.cpp
index 4349794e658..cc03c227acd 100644
--- a/src/rt/rust_chan.cpp
+++ b/src/rt/rust_chan.cpp
@@ -10,6 +10,7 @@ rust_chan::rust_chan(rust_task *task,
                      task(task),
                      port(port),
                      buffer(task->dom, unit_sz) {
+    ++task->ref_count;
     if (port) {
         associate(port);
     }
@@ -23,6 +24,7 @@ rust_chan::~rust_chan() {
 
     A(task->dom, is_associated() == false,
       "Channel must be disassociated before being freed.");
+    --task->ref_count;
 }
 
 /**
@@ -31,10 +33,10 @@ rust_chan::~rust_chan() {
 void rust_chan::associate(maybe_proxy<rust_port> *port) {
     this->port = port;
     if (port->is_proxy() == false) {
-        scoped_lock sync(port->referent()->lock);
         LOG(task, task,
             "associating chan: 0x%" PRIxPTR " with port: 0x%" PRIxPTR,
             this, port);
+        ++this->ref_count;
         this->port->referent()->chans.push(this);
     }
 }
@@ -50,10 +52,10 @@ void rust_chan::disassociate() {
     A(task->dom, is_associated(), "Channel must be associated with a port.");
 
     if (port->is_proxy() == false) {
-        scoped_lock sync(port->referent()->lock);
         LOG(task, task,
             "disassociating chan: 0x%" PRIxPTR " from port: 0x%" PRIxPTR,
             this, port->referent());
+        --this->ref_count;
         port->referent()->chans.swap_delete(this);
     }
 
@@ -83,7 +85,6 @@ void rust_chan::send(void *sptr) {
         buffer.dequeue(NULL);
     } else {
         rust_port *target_port = port->referent();
-        scoped_lock sync(target_port->lock);
         if (target_port->task->blocked_on(target_port)) {
             DLOG(dom, comm, "dequeued in rendezvous_ptr");
             buffer.dequeue(target_port->task->rendezvous_ptr);