This is the mail archive of the frysk-cvs@sources.redhat.com mailing list for the frysk project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[SCM] master: Avoid spurious waits in CountDownLatch.await


The branch, master has been updated
       via  d7c815e89593b5133268c9574950ca09b01eb6c7 (commit)
      from  943add0b4c20c6965b068c3a5e8923d367441abf (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email.

- Log -----------------------------------------------------------------
commit d7c815e89593b5133268c9574950ca09b01eb6c7
Author: Tim Moore <moore@blackbox.bricoworks.com>
Date:   Thu Nov 22 18:29:35 2007 +0100

    Avoid spurious waits in CountDownLatch.await
    
    frysk-core/frysk/util/ChangeLog
    2007-11-22  Tim Moore  <timoore@redhat.com>
    
    	* CountDownLatch.java (await): Loop to avoid spurious wakeup.

-----------------------------------------------------------------------

Summary of changes:
 frysk-core/frysk/util/ChangeLog           |    4 ++++
 frysk-core/frysk/util/CountDownLatch.java |   27 +++++++++++++++++++++------
 2 files changed, 25 insertions(+), 6 deletions(-)

First 500 lines of diff:
diff --git a/frysk-core/frysk/util/ChangeLog b/frysk-core/frysk/util/ChangeLog
index 5c50a53..0eb921d 100644
--- a/frysk-core/frysk/util/ChangeLog
+++ b/frysk-core/frysk/util/ChangeLog
@@ -1,3 +1,7 @@
+2007-11-22  Tim Moore  <timoore@redhat.com>
+
+	* CountDownLatch.java (await): Loop to avoid spurious wakeup.
+
 2007-11-21  Sami Wagiaalla  <swagiaal@redhat.com>
 
 	* StacktraceAction.java: Now passes numberOfFrames argument.
diff --git a/frysk-core/frysk/util/CountDownLatch.java b/frysk-core/frysk/util/CountDownLatch.java
index a972cfd..b191782 100644
--- a/frysk-core/frysk/util/CountDownLatch.java
+++ b/frysk-core/frysk/util/CountDownLatch.java
@@ -55,18 +55,33 @@ public class CountDownLatch {
 
     public void await()
         throws InterruptedException {
-        await(0);
+        while (count != 0) {
+            try {
+                wait();
+            }
+            catch (InterruptedException e) {
+                throw e;
+            }
+        }
     }
 
     public synchronized boolean await(long timeout)
         throws InterruptedException {
         if (count == 0)
             return true;
-        try {
-            wait(timeout);
-        }
-        catch (InterruptedException e) {
-            throw e;
+        long now = System.currentTimeMillis();
+        while (count != 0) {
+            long later = now + timeout;
+            try {
+                wait(timeout);
+            }
+            catch (InterruptedException e) {
+                throw e;
+            }
+            now = System.currentTimeMillis();
+            if (now >= later)
+                break;
+            timeout = later - now;
         }
         // Either the count is 0 or we timed out
         return count == 0;


hooks/post-receive
--
frysk system monitor/debugger


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]