[jboss-svn-commits] JBL Code SVN: r29491 - labs/jbosstm/workspace/adinn/byteman/trunk/src/org/jboss/byteman/synchronization.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Mon Sep 28 11:01:55 EDT 2009
Author: kabir.khan at jboss.com
Date: 2009-09-28 11:01:55 -0400 (Mon, 28 Sep 2009)
New Revision: 29491
Modified:
labs/jbosstm/workspace/adinn/byteman/trunk/src/org/jboss/byteman/synchronization/Waiter.java
Log:
[BYTEMAN-43] Avoid spurious wakeups in Waiter.waitFor()
Modified: labs/jbosstm/workspace/adinn/byteman/trunk/src/org/jboss/byteman/synchronization/Waiter.java
===================================================================
--- labs/jbosstm/workspace/adinn/byteman/trunk/src/org/jboss/byteman/synchronization/Waiter.java 2009-09-28 14:50:54 UTC (rev 29490)
+++ labs/jbosstm/workspace/adinn/byteman/trunk/src/org/jboss/byteman/synchronization/Waiter.java 2009-09-28 15:01:55 UTC (rev 29491)
@@ -45,23 +45,30 @@
public void waitFor(long millisecs)
{
+ long start = System.currentTimeMillis();
+ long waitFor = millisecs == 0 ? 0 : millisecs;
synchronized(this) {
waiting = true;
-
- if (!signalled) {
+ while (!signalled && waitFor >= 0){
try {
- this.wait(millisecs);
+ this.wait(waitFor);
} catch (InterruptedException e) {
// ignore
}
- } else {
- // notify in case a signalling thread was waiting
- this.notifyAll();
+
+ if (!signalled)
+ {
+ waitFor = millisecs == 0 ? 0 : millisecs + start - System.currentTimeMillis();
+ System.out.println("NOT_SIGNALLED new timeout " + waitFor);
+ }
}
+ if (signalled) {
+ // notify in case a signalling thread was waiting
+ this.notifyAll();
+ }
}
// if a signalKill was used then we have to throw an exception otherwise we just return
-
if (killed) {
throw new ExecuteException("Waiter.waitFor : killed thread waiting for " + waiterFor);
}
More information about the jboss-svn-commits
mailing list