[jboss-svn-commits] JBL Code SVN: r19846 - labs/jbossrules/branches/4.0.x/drools-core/src/main/java/org/drools/common.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Sat May 3 13:25:57 EDT 2008
Author: mark.proctor at jboss.com
Date: 2008-05-03 13:25:57 -0400 (Sat, 03 May 2008)
New Revision: 19846
Modified:
labs/jbossrules/branches/4.0.x/drools-core/src/main/java/org/drools/common/AbstractWorkingMemory.java
Log:
JBRULES-1572 sometimes getting ClassFieldExtractor error
-AbstractWorkingMemory.actionQueue now has synchronised block access
-halt, firing and evaluatingActionQueue are now volatile
Modified: labs/jbossrules/branches/4.0.x/drools-core/src/main/java/org/drools/common/AbstractWorkingMemory.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-core/src/main/java/org/drools/common/AbstractWorkingMemory.java 2008-05-03 16:57:56 UTC (rev 19845)
+++ labs/jbossrules/branches/4.0.x/drools-core/src/main/java/org/drools/common/AbstractWorkingMemory.java 2008-05-03 17:25:57 UTC (rev 19846)
@@ -86,9 +86,9 @@
InternalWorkingMemoryActions,
EventSupport,
PropertyChangeListener {
-
- private static final long serialVersionUID = 405L;
-
+
+ private static final long serialVersionUID = 405L;
+
// ------------------------------------------------------------
// Constants
// ------------------------------------------------------------
@@ -137,9 +137,9 @@
/** Rule-firing agenda. */
protected DefaultAgenda agenda;
- protected final LinkedList actionQueue = new LinkedList();
+ protected final LinkedList actionQueue = new LinkedList();
- protected boolean evaluatingActionQueue;
+ protected volatile boolean evaluatingActionQueue;
protected final ReentrantLock lock = new ReentrantLock();
@@ -154,9 +154,9 @@
private List liaPropagations = Collections.EMPTY_LIST;
/** Flag to determine if a rule is currently being fired. */
- protected boolean firing;
+ protected volatile boolean firing;
- protected boolean halt;
+ protected volatile boolean halt;
private int processCounter;
@@ -464,9 +464,7 @@
}
}
- if ( !this.actionQueue.isEmpty() ) {
- executeQueuedActions();
- }
+ executeQueuedActions();
boolean noneFired = true;
@@ -477,9 +475,7 @@
while ( continueFiring( fireLimit ) && this.agenda.fireNextItem( agendaFilter ) ) {
fireLimit = updateFireLimit( fireLimit );
noneFired = false;
- if ( !this.actionQueue.isEmpty() ) {
- executeQueuedActions();
- }
+ executeQueuedActions();
}
} finally {
this.firing = false;
@@ -916,9 +912,7 @@
object,
propagationContext );
- if ( !this.actionQueue.isEmpty() ) {
- executeQueuedActions();
- }
+ executeQueuedActions();
this.workingMemoryEventSupport.fireObjectInserted( propagationContext,
handle,
@@ -1060,9 +1054,7 @@
this.handleFactory.destroyFactHandle( handle );
- if ( !this.actionQueue.isEmpty() ) {
- executeQueuedActions();
- }
+ executeQueuedActions();
} finally {
this.lock.unlock();
}
@@ -1085,9 +1077,9 @@
this.identityMap.remove( handle );
}
}
-
- private Map modifyContexts = new HashMap();
+ private Map modifyContexts = new HashMap();
+
public void modifyRetract(final FactHandle factHandle) {
modifyRetract( factHandle,
null,
@@ -1120,9 +1112,10 @@
activation,
this.agenda.getActiveActivations(),
this.agenda.getDormantActivations() );
-
- modifyContexts.put( handle, propagationContext );
-
+
+ modifyContexts.put( handle,
+ propagationContext );
+
doRetract( handle,
propagationContext );
@@ -1162,7 +1155,7 @@
final Object originalObject = (handle.isShadowFact()) ? ((ShadowProxy) handle.getObject()).getShadowedObject() : handle.getObject();
if ( this.maintainTms ) {
- int status = handle.getEqualityKey().getStatus();
+ int status = handle.getEqualityKey().getStatus();
// now use an existing EqualityKey, if it exists, else create a new one
EqualityKey key = this.tms.get( object );
@@ -1184,7 +1177,7 @@
activation.getPropagationContext().releaseResources();
}
// Nowretract any trace of the original fact
- final PropagationContext propagationContext = ( PropagationContext ) this.modifyContexts.remove( handle );
+ final PropagationContext propagationContext = (PropagationContext) this.modifyContexts.remove( handle );
doInsert( handle,
object,
@@ -1198,9 +1191,8 @@
propagationContext.clearRetractedTuples();
- if ( !this.actionQueue.isEmpty() ) {
- executeQueuedActions();
- }
+ executeQueuedActions();
+
} finally {
this.lock.unlock();
}
@@ -1304,28 +1296,30 @@
propagationContext.clearRetractedTuples();
- if ( !this.actionQueue.isEmpty() ) {
- executeQueuedActions();
- }
+ executeQueuedActions();
} finally {
this.lock.unlock();
}
}
public void executeQueuedActions() {
- if( ! evaluatingActionQueue ) {
- evaluatingActionQueue = true;
- WorkingMemoryAction action = null;
-
- while ( actionQueue.size() != 0 && ( action = (WorkingMemoryAction) actionQueue.removeFirst() ) != null ) {
- action.execute( this );
+ synchronized ( this.actionQueue ) {
+ if ( !this.actionQueue.isEmpty() && !this.evaluatingActionQueue ) {
+ this.evaluatingActionQueue = true;
+ WorkingMemoryAction action = null;
+
+ while ( this.actionQueue.size() != 0 && (action = (WorkingMemoryAction) this.actionQueue.removeFirst()) != null ) {
+ action.execute( this );
+ }
+ this.evaluatingActionQueue = false;
}
- evaluatingActionQueue = false;
}
}
public void queueWorkingMemoryAction(final WorkingMemoryAction action) {
- this.actionQueue.add( action );
+ synchronized ( this.actionQueue ) {
+ this.actionQueue.add( action );
+ }
}
public void removeLogicalDependencies(final Activation activation,
More information about the jboss-svn-commits
mailing list