[jboss-svn-commits] JBL Code SVN: r29493 - in labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_0/src/org/jboss/byteman: synchronization and 1 other directory.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Mon Sep 28 11:17:10 EDT 2009


Author: adinn
Date: 2009-09-28 11:17:10 -0400 (Mon, 28 Sep 2009)
New Revision: 29493

Modified:
   labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_0/src/org/jboss/byteman/rule/helper/Helper.java
   labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_0/src/org/jboss/byteman/synchronization/Waiter.java
Log:
backported fixes for BYTEMAN-42, BYTEMAN-38 and BYTEMAN-43 for 1.0.3.CP01 release

Modified: labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_0/src/org/jboss/byteman/rule/helper/Helper.java
===================================================================
--- labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_0/src/org/jboss/byteman/rule/helper/Helper.java	2009-09-28 15:07:25 UTC (rev 29492)
+++ labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_0/src/org/jboss/byteman/rule/helper/Helper.java	2009-09-28 15:17:10 UTC (rev 29493)
@@ -164,6 +164,16 @@
     }
 
     /**
+     * call trace("out, message").
+     * @param message
+     * @return true
+     */
+    public boolean trace(String message)
+    {
+        return trace("out", message);
+    }
+
+    /**
      * write the supplied message to the trace stream identified by identifier, creating a new stream
      * if none exists
      * @param identifier an identifier used subsequently to identify the trace output stream
@@ -190,6 +200,16 @@
     }
 
     /**
+     * call traceln("out", message).
+     * @param message
+     * @return true
+     */
+    public boolean traceln(String message)
+    {
+        return traceln("out", message);
+    }
+    
+    /**
      * write the supplied message to the trace stream identified by identifier, creating a new stream
      * if none exists, and append a new line
      * @param identifier an identifier used subsequently to identify the trace output stream
@@ -433,9 +453,12 @@
                         // do nothing
                     }
                 }
-                // remove the association between the waiter and the wait map
-                removeWaiter(waiter);
             }
+
+            // remove the association between the waiter and the wait map
+            synchronized (waitMap) {
+                removeWaiter(identifier);
+            }
             return true;
         }
     }
@@ -515,9 +538,11 @@
                         // do nothing
                     }
                 }
-                // remove the association between the waiter and the wait map
-                removeWaiter(waiter);
             }
+            // remove the association between the waiter and the wait map
+            synchronized (waitMap) {
+                removeWaiter(identifier);
+            }
             return true;
         }
     }

Modified: labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_0/src/org/jboss/byteman/synchronization/Waiter.java
===================================================================
--- labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_0/src/org/jboss/byteman/synchronization/Waiter.java	2009-09-28 15:07:25 UTC (rev 29492)
+++ labs/jbosstm/workspace/adinn/byteman/branches/Byteman_1_0/src/org/jboss/byteman/synchronization/Waiter.java	2009-09-28 15:17:10 UTC (rev 29493)
@@ -45,25 +45,32 @@
 
     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 waiting thread killed for " + waiterFor);
+            throw new ExecuteException("Waiter.waitFor : killed thread waiting for " + waiterFor);
         }
     }
 
@@ -126,4 +133,12 @@
      */
 
     private boolean waiting;
+
+    /**
+     * getter for signalled flag
+     * @return signalled
+     */
+    public boolean isSignalled() {
+        return signalled;
+    }
 }



More information about the jboss-svn-commits mailing list