about summary refs log tree commit diff
path: root/src/rt/rust_task.cpp
diff options
context:
space:
mode:
authorBen Blum <bblum@andrew.cmu.edu>2012-08-21 18:03:41 -0400
committerBen Blum <bblum@andrew.cmu.edu>2012-08-21 18:03:41 -0400
commit47cca22d5455d2d60226ead907fd627784701ef5 (patch)
tree24562d36717fae36f3e2dfbe47f2b49cd13eb3b7 /src/rt/rust_task.cpp
parent0229bc4defdaa6bad77269204279ed1a37b3aa9f (diff)
downloadrust-47cca22d5455d2d60226ead907fd627784701ef5.tar.gz
rust-47cca22d5455d2d60226ead907fd627784701ef5.zip
Bypass lifecycle_lock in inhibit_kill/allow_kill for 3% to 5% speedup. Close #3213.
Diffstat (limited to 'src/rt/rust_task.cpp')
-rw-r--r--src/rt/rust_task.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/rt/rust_task.cpp b/src/rt/rust_task.cpp
index 061e87ebff8..791c6a6551f 100644
--- a/src/rt/rust_task.cpp
+++ b/src/rt/rust_task.cpp
@@ -631,27 +631,29 @@ rust_task::on_rust_stack() {
     }
 }
 
+// NB: In inhibit_kill and allow_kill, helgrind would complain that we need to
+// hold lifecycle_lock while accessing disallow_kill. Even though another
+// killing task may access disallow_kill concurrently, this is not racy
+// because the killer only cares if this task is blocking, and block() already
+// uses proper locking. See https://github.com/mozilla/rust/issues/3213 .
+
 void
 rust_task::inhibit_kill() {
-    scoped_lock with(lifecycle_lock);
     // Here might be good, though not mandatory, to check if we have to die.
     disallow_kill++;
 }
 
 void
 rust_task::allow_kill() {
-    scoped_lock with(lifecycle_lock);
     assert(disallow_kill > 0 && "Illegal allow_kill(): already killable!");
     disallow_kill--;
 }
 
 void rust_task::inhibit_yield() {
-    scoped_lock with(lifecycle_lock);
     disallow_yield++;
 }
 
 void rust_task::allow_yield() {
-    scoped_lock with(lifecycle_lock);
     assert(disallow_yield > 0 && "Illegal allow_yield(): already yieldable!");
     disallow_yield--;
 }