From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10300 invoked by alias); 22 Nov 2007 20:53:28 -0000 Received: (qmail 10275 invoked by uid 9639); 22 Nov 2007 20:53:27 -0000 Date: Thu, 22 Nov 2007 20:53:00 -0000 Message-ID: <20071122205327.10260.qmail@sourceware.org> From: moore@sourceware.org To: frysk-cvs@sourceware.org Subject: [SCM] master: Avoid spurious waits in CountDownLatch.await X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: 943add0b4c20c6965b068c3a5e8923d367441abf X-Git-Newrev: d7c815e89593b5133268c9574950ca09b01eb6c7 Mailing-List: contact frysk-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: frysk-cvs-owner@sourceware.org Reply-To: frysk@sourceware.org X-SW-Source: 2007-q4/txt/msg00433.txt.bz2 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 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 * 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 + + * CountDownLatch.java (await): Loop to avoid spurious wakeup. + 2007-11-21 Sami Wagiaalla * 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