public void queueWorkingMemoryAction(final WorkingMemoryAction action) { try { startOperation(); getActionQueue().add( action ); this.agenda.notifyHalt(); } finally { endOperation(); } }
public void executeQueuedActions() { try { startOperation(); if ( evaluatingActionQueue.compareAndSet( false, true ) ) { try { if ( actionQueue!= null && !actionQueue.isEmpty() ) { WorkingMemoryAction action = null; while ( (action = actionQueue.poll()) != null ) { try { action.execute( this ); } catch ( Exception e ) { throw new RuntimeDroolsException( "Unexpected exception executing action " + action.toString(), e ); } } } } finally { evaluatingActionQueue.compareAndSet( true, false ); } } } finally { endOperation(); } }
public void setGlobal(final String identifier, final Object value) { // Cannot set null values if ( value == null ) { return; } try { this.ruleBase.readLock(); startOperation(); // Make sure the global has been declared in the RuleBase final Map globalDefintions = this.ruleBase.getGlobals(); final Class type = (Class) globalDefintions.get( identifier ); if ( (type == null) ) { throw new RuntimeException( "Unexpected global [" + identifier + "]" ); } else if ( !type.isInstance( value ) ) { throw new RuntimeException( "Illegal class for global. " + "Expected [" + type.getName() + "], " + "found [" + value.getClass().getName() + "]." ); } else { this.globalResolver.setGlobal( identifier, value ); } } finally { endOperation(); this.ruleBase.readUnlock(); } }
public void stopPartitionManagers() { startOperation(); try { if ( this.ruleBase.getConfiguration().isMultithreadEvaluation() ) { ExternalExecutorService service = this.threadPool.get(); if ( this.threadPool.compareAndSet( service, null ) ) { service.shutdown(); partitionManager.shutdown(); } } } finally { endOperation(); } }
} finally { ruleBase.readUnlock(); endOperation(); this.firing.set( false );
/** * This method is called to start the multiple partition threads when * running in multi-thread mode */ public void startPartitionManagers() { startOperation(); try { if ( this.ruleBase.getConfiguration().isMultithreadEvaluation() ) { int maxThreads = (this.ruleBase.getConfiguration().getMaxThreads() > 0) ? this.ruleBase.getConfiguration().getMaxThreads() : this.ruleBase.getPartitionIds().size(); if ( this.threadPool.compareAndSet( null, createExecutorService( maxThreads ) ) ) { this.partitionManager.setPool( this.threadPool.get() ); } } } finally { endOperation(); } }
this.wm.endOperation(); this.ruleBase.readUnlock(); this.lock.unlock();
this.wm.endOperation(); this.ruleBase.readUnlock(); this.lock.unlock();