public inbox for frysk-cvs@sourceware.org
help / color / mirror / Atom feed
* [SCM]  master: Avoid spurious waits in CountDownLatch.await
@ 2007-11-22 20:53 moore
  0 siblings, 0 replies; only message in thread
From: moore @ 2007-11-22 20:53 UTC (permalink / raw)
  To: frysk-cvs

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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2007-11-22 20:53 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-11-22 20:53 [SCM] master: Avoid spurious waits in CountDownLatch.await moore

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).