|
From: <jom...@us...> - 2011-03-01 19:56:36
|
Revision: 1631
http://jason.svn.sourceforge.net/jason/?rev=1631&view=rev
Author: jomifred
Date: 2011-03-01 19:56:30 +0000 (Tue, 01 Mar 2011)
Log Message:
-----------
fix a bug reported by Francisco Grimaldo related to Execution Control
Modified Paths:
--------------
trunk/src/jason/control/ExecutionControl.java
trunk/src/jason/infra/centralised/CentralisedExecutionControl.java
Modified: trunk/src/jason/control/ExecutionControl.java
===================================================================
--- trunk/src/jason/control/ExecutionControl.java 2011-02-22 11:52:25 UTC (rev 1630)
+++ trunk/src/jason/control/ExecutionControl.java 2011-03-01 19:56:30 UTC (rev 1631)
@@ -81,8 +81,10 @@
}
// update number of agents if finished by timeout
- if (to)
+ if (to) {
+ if (logger.isLoggable(Level.FINE)) logger.fine("Cycle "+getCycleNumber()+" finished by timeout!");
updateNumberOfAgents();
+ }
} catch (Exception e) {
e.printStackTrace();
}
@@ -130,7 +132,7 @@
* annotation.
*/
public void receiveFinishedCycle(String agName, boolean breakpoint, int cycle) {
- if (nbAgs < 0 || cycle != this.cycleNumber) {
+ if (nbAgs < 0 || cycle != this.cycleNumber || finished.size()+1 > nbAgs) {
updateNumberOfAgents();
}
if (cycle == this.cycleNumber && runningCycle) { // the agent finished the current cycle
Modified: trunk/src/jason/infra/centralised/CentralisedExecutionControl.java
===================================================================
--- trunk/src/jason/infra/centralised/CentralisedExecutionControl.java 2011-02-22 11:52:25 UTC (rev 1630)
+++ trunk/src/jason/infra/centralised/CentralisedExecutionControl.java 2011-03-01 19:56:30 UTC (rev 1631)
@@ -30,6 +30,8 @@
import jason.mas2j.ClassParameters;
import jason.runtime.RuntimeServicesInfraTier;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -47,6 +49,8 @@
private static Logger logger = Logger.getLogger(CentralisedExecutionControl.class.getName());
+ protected ExecutorService executor = Executors.newSingleThreadExecutor();
+
public CentralisedExecutionControl(ClassParameters userControlClass, RunCentralisedMAS masRunner) throws JasonException {
this.masRunner = masRunner;
try {
@@ -80,13 +84,17 @@
infraArch.receiveSyncSignal();
}
- public void informAllAgsToPerformCycle(int cycle) {
- synchronized (masRunner.getAgs()) {
- for (CentralisedAgArch ag: masRunner.getAgs().values()) {
- ag.getUserAgArch().setCycleNumber(cycle);
- ag.receiveSyncSignal();
+ public void informAllAgsToPerformCycle(final int cycle) {
+ executor.execute(new Runnable() {
+ public void run() {
+ synchronized (masRunner.getAgs()) {
+ for (CentralisedAgArch ag: masRunner.getAgs().values()) {
+ ag.getUserAgArch().setCycleNumber(cycle);
+ ag.receiveSyncSignal();
+ }
+ }
}
- }
+ });
}
public Document getAgState(String agName) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|