[jboss-svn-commits] JBL Code SVN: r9595 - labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Mon Feb 19 08:39:09 EST 2007


Author: tirelli
Date: 2007-02-19 08:39:09 -0500 (Mon, 19 Feb 2007)
New Revision: 9595

Modified:
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AbstractRuleBase.java
Log:
JBRULES-603: adding some comments to clarify the code

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AbstractRuleBase.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AbstractRuleBase.java	2007-02-19 13:28:32 UTC (rev 9594)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AbstractRuleBase.java	2007-02-19 13:39:09 UTC (rev 9595)
@@ -243,6 +243,8 @@
     public void addPackage(final Package newPkg) throws PackageIntegrationException {
         newPkg.checkValidity();
         final Package pkg = (Package) this.pkgs.get( newPkg.getName() );
+        // INVARIANT: lastAquiredLock always contains the index of the last aquired lock +1 
+        // in the working memory array 
         int lastAquiredLock = 0;
         // get a snapshot of current working memories for locking
         AbstractWorkingMemory[] wms = (AbstractWorkingMemory[]) this.workingMemories.keySet().toArray( new AbstractWorkingMemory[this.workingMemories.size()] );
@@ -290,6 +292,8 @@
         } finally {
             // Iterate each workingMemory and attempt to fire any rules, that were activated as a result 
             // of the new rule addition. Unlock after fireAllRules();
+            
+            // as per the INVARIANT defined above, we need to iterate from lastAquiredLock-1 to 0. 
             for ( lastAquiredLock--; lastAquiredLock > -1; lastAquiredLock-- ) {
                 wms[lastAquiredLock].fireAllRules();
                 wms[lastAquiredLock].getLock().unlock();
@@ -356,6 +360,8 @@
     public void removePackage(final String packageName) {
         final Package pkg = (Package) this.pkgs.get( packageName );
 
+        // INVARIANT: lastAquiredLock always contains the index of the last aquired lock +1 
+        // in the working memory array 
         int lastAquiredLock = 0;
         // get a snapshot of current working memories for locking
         AbstractWorkingMemory[] wms = (AbstractWorkingMemory[]) this.workingMemories.keySet().toArray( new AbstractWorkingMemory[this.workingMemories.size()] );
@@ -397,6 +403,8 @@
         } finally {
             // Iterate each workingMemory and attempt to fire any rules, that were activated as a result 
             // of the new rule addition. Unlock after fireAllRules();
+
+            // as per the INVARIANT defined above, we need to iterate from lastAquiredLock-1 to 0. 
             for ( lastAquiredLock--; lastAquiredLock > -1; lastAquiredLock-- ) {
                 wms[lastAquiredLock].fireAllRules();
                 wms[lastAquiredLock].getLock().unlock();
@@ -409,6 +417,8 @@
         final Package pkg = (Package) this.pkgs.get( packageName );
         final Rule rule = pkg.getRule( ruleName );
 
+        // INVARIANT: lastAquiredLock always contains the index of the last aquired lock +1 
+        // in the working memory array 
         int lastAquiredLock = 0;
         // get a snapshot of current working memories for locking
         AbstractWorkingMemory[] wms = (AbstractWorkingMemory[]) this.workingMemories.keySet().toArray( new AbstractWorkingMemory[this.workingMemories.size()] );
@@ -426,6 +436,8 @@
         } finally {
             // Iterate each workingMemory and attempt to fire any rules, that were activated as a result 
             // of the new rule addition. Unlock after fireAllRules();
+
+            // as per the INVARIANT defined above, we need to iterate from lastAquiredLock-1 to 0. 
             for ( lastAquiredLock--; lastAquiredLock > -1; lastAquiredLock-- ) {
                 wms[lastAquiredLock].getLock().unlock();
             }




More information about the jboss-svn-commits mailing list