[commit: ghc] master: tryGrabCapability should be using TRY_ACQUIRE_LOCK (9123845)

git at git.haskell.org git at git.haskell.org
Thu Sep 15 12:23:51 UTC 2016


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/912384535d2ac7452d3bcda34cdee238e30600c9/ghc

>---------------------------------------------------------------

commit 912384535d2ac7452d3bcda34cdee238e30600c9
Author: Simon Marlow <marlowsd at gmail.com>
Date:   Thu Sep 15 11:34:05 2016 +0100

    tryGrabCapability should be using TRY_ACQUIRE_LOCK


>---------------------------------------------------------------

912384535d2ac7452d3bcda34cdee238e30600c9
 rts/Capability.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/rts/Capability.c b/rts/Capability.c
index 6979c63..6ca34f8 100644
--- a/rts/Capability.c
+++ b/rts/Capability.c
@@ -973,8 +973,10 @@ prodCapability (Capability *cap, Task *task)
 rtsBool
 tryGrabCapability (Capability *cap, Task *task)
 {
+    int r;
     if (cap->running_task != NULL) return rtsFalse;
-    ACQUIRE_LOCK(&cap->lock);
+    r = TRY_ACQUIRE_LOCK(&cap->lock);
+    if (r != 0) return rtsFalse;
     if (cap->running_task != NULL) {
         RELEASE_LOCK(&cap->lock);
         return rtsFalse;



More information about the ghc-commits mailing list