diff --git a/sre/io.janusproject/io.janusproject.plugin/src/main/sarl/io/sarl/sre/capacities/InternalEventBus.sarl b/sre/io.janusproject/io.janusproject.plugin/src/main/sarl/io/sarl/sre/capacities/InternalEventBus.sarl index 8b0f3f6df1..73b4bc3e55 100644 --- a/sre/io.janusproject/io.janusproject.plugin/src/main/sarl/io/sarl/sre/capacities/InternalEventBus.sarl +++ b/sre/io.janusproject/io.janusproject.plugin/src/main/sarl/io/sarl/sre/capacities/InternalEventBus.sarl @@ -92,7 +92,7 @@ capacity InternalEventBusCapacity { * @since 0.7 */ def fireEventAndWait(^event : Event, gatherEvents : boolean, thrownExceptions : boolean, - listener : Object) : Iterable + listener : Object) : ConcurrentLinkedDeque /** Fire the given event into the agent context, and wait for the execution of all the event handlers. * @@ -111,7 +111,7 @@ capacity InternalEventBusCapacity { * to the agent's logger, and never thrown outside this function. * @return the events that were received during the execution of this function. These events are not fired into the agent context yet. */ - def fireEventAndWait(^event : Event, gatherEvents : boolean, thrownExceptions : boolean) : Iterable + def fireEventAndWait(^event : Event, gatherEvents : boolean, thrownExceptions : boolean) : ConcurrentLinkedDeque /** Fire the given event into the agent context, and do not wait for the termination of the event handlers. * diff --git a/sre/io.janusproject/io.janusproject.plugin/src/main/sarl/io/sarl/sre/internal/PlatformEventEmitters.sarl b/sre/io.janusproject/io.janusproject.plugin/src/main/sarl/io/sarl/sre/internal/PlatformEventEmitters.sarl index ba0f130c82..e73cddfd3b 100644 --- a/sre/io.janusproject/io.janusproject.plugin/src/main/sarl/io/sarl/sre/internal/PlatformEventEmitters.sarl +++ b/sre/io.janusproject/io.janusproject.plugin/src/main/sarl/io/sarl/sre/internal/PlatformEventEmitters.sarl @@ -59,6 +59,7 @@ import java.util.UUID import java.util.logging.Logger import static io.sarl.sre.services.lifecycle.AgentLife.* +import java.util.concurrent.ConcurrentLinkedDeque /** Emit the space platform events. * @@ -219,7 +220,7 @@ class AgentEventEmitter implements LifecycleServiceListener { defSpace.emit(null, ^event) [agentId != it.UUID] } - override agentDestroyed(^agent : Agent, outerContexts : Iterable) { + override agentDestroyed(^agent : Agent, outerContexts : ConcurrentLinkedDeque) { this.logger.config[MessageFormat::format(Messages::AgentEventEmitter_1, ^agent.ID)] val size = outerContexts.size val spaces = newArrayOfSize(size) diff --git a/sre/io.janusproject/io.janusproject.plugin/src/main/sarl/io/sarl/sre/services/lifecycle/AbstractCreatorFactory.sarl b/sre/io.janusproject/io.janusproject.plugin/src/main/sarl/io/sarl/sre/services/lifecycle/AbstractCreatorFactory.sarl index ab6b1f53ae..ee0b415d9a 100644 --- a/sre/io.janusproject/io.janusproject.plugin/src/main/sarl/io/sarl/sre/services/lifecycle/AbstractCreatorFactory.sarl +++ b/sre/io.janusproject/io.janusproject.plugin/src/main/sarl/io/sarl/sre/services/lifecycle/AbstractCreatorFactory.sarl @@ -54,6 +54,7 @@ abstract class AbstractCreatorFactory implements AgentCreatorProvider { */ def mergeSkillProviders(providers : ConcurrentLinkedDeque) : DynamicSkillProvider { if (providers !== null) { + //TODO tune this iterator call that seems to be useless or not the best option var iterator = providers.iterator if (iterator.hasNext) { if (this.skillProvider === null) { @@ -74,9 +75,9 @@ abstract class AbstractCreatorFactory implements AgentCreatorProvider { */ private static class CreatorFactory0 implements DynamicSkillProvider { - val providers : Iterable + val providers : ConcurrentLinkedDeque - new (providers : Iterable) { + new (providers : ConcurrentLinkedDeque) { this.providers = providers } diff --git a/sre/io.janusproject/io.janusproject.plugin/src/main/sarl/io/sarl/sre/services/lifecycle/AbstractLifecycleService.sarl b/sre/io.janusproject/io.janusproject.plugin/src/main/sarl/io/sarl/sre/services/lifecycle/AbstractLifecycleService.sarl index ed4de7c872..aafccbe69e 100644 --- a/sre/io.janusproject/io.janusproject.plugin/src/main/sarl/io/sarl/sre/services/lifecycle/AbstractLifecycleService.sarl +++ b/sre/io.janusproject/io.janusproject.plugin/src/main/sarl/io/sarl/sre/services/lifecycle/AbstractLifecycleService.sarl @@ -146,7 +146,7 @@ abstract class AbstractLifecycleService extends AbstractSreService implements Li * @param agents the destroyed agent. * @param outerContexts the contexts in which the agent w destroyed. */ - protected def fireAgentDestroy(^agent : Agent, outerContexts : Iterable) { + protected def fireAgentDestroy(^agent : Agent, outerContexts : ConcurrentLinkedDeque) { // Notify the listeners on the spawn events (not restricted to a single agent) this.globalListeners.notifyListeners(typeof(LifecycleServiceListener)) [ agentDestroyed(^agent, outerContexts) @@ -435,7 +435,7 @@ abstract class AbstractLifecycleService extends AbstractSreService implements Li } protected def fireAgentDestructionEvents(^agent : Agent, defaultContextBeforeKilled : ContextReference, - leavedContexts : Iterable) { + leavedContexts : ConcurrentLinkedDeque) { // Leave the default context because the ExternalContextAccessSkill does not fire events related // to the default space. this.platformContextEventEmitter.memberLeft(defaultContextBeforeKilled.context, diff --git a/sre/io.janusproject/io.janusproject.plugin/src/main/sarl/io/sarl/sre/services/lifecycle/LifecycleService.sarl b/sre/io.janusproject/io.janusproject.plugin/src/main/sarl/io/sarl/sre/services/lifecycle/LifecycleService.sarl index 2c48e7f8a4..00e2c47de2 100644 --- a/sre/io.janusproject/io.janusproject.plugin/src/main/sarl/io/sarl/sre/services/lifecycle/LifecycleService.sarl +++ b/sre/io.janusproject/io.janusproject.plugin/src/main/sarl/io/sarl/sre/services/lifecycle/LifecycleService.sarl @@ -26,6 +26,7 @@ import io.sarl.lang.core.DynamicSkillProvider import io.sarl.sre.services.context.Context import java.util.EventListener import java.util.UUID +import java.util.concurrent.ConcurrentLinkedDeque /** * This service provides the tools to manage the life-cycle of the agents. @@ -144,7 +145,7 @@ interface LifecycleServiceListener extends EventListener { * @param agent the destroyed agent. * @param outerContexts the contexts from which the given agent were removed after its destruction. */ - def agentDestroyed(^agent : Agent, outerContexts : Iterable) + def agentDestroyed(^agent : Agent, outerContexts : ConcurrentLinkedDeque) /** * Invoked when the agent spawning has failed. diff --git a/sre/io.janusproject/io.janusproject.plugin/src/main/sarl/io/sarl/sre/skills/internal/InternalEventBusSkill.sarl b/sre/io.janusproject/io.janusproject.plugin/src/main/sarl/io/sarl/sre/skills/internal/InternalEventBusSkill.sarl index cb7f64aeef..56477d6b06 100644 --- a/sre/io.janusproject/io.janusproject.plugin/src/main/sarl/io/sarl/sre/skills/internal/InternalEventBusSkill.sarl +++ b/sre/io.janusproject/io.janusproject.plugin/src/main/sarl/io/sarl/sre/skills/internal/InternalEventBusSkill.sarl @@ -191,7 +191,7 @@ skill InternalEventBusSkill extends Skill implements InternalEventBusCapacity { return new ConcurrentLinkedDeque } - def fireEventAndWait(^event : Event, gatherEvents : boolean, thrownExceptions : boolean) : Iterable { + def fireEventAndWait(^event : Event, gatherEvents : boolean, thrownExceptions : boolean) : ConcurrentLinkedDeque { if (getLife(owner).state.blockingEventHandling) { val logger = getLogger if (gatherEvents) { @@ -211,7 +211,7 @@ skill InternalEventBusSkill extends Skill implements InternalEventBusCapacity { } this.eventBus.immediateDispatch(^event, thrownExceptions, logger) } - return emptyList + return new ConcurrentLinkedDeque } def fireEvent(^event : Event) {