Skip to content

Commit

Permalink
[sre] Buffering the capacity for faster access.
Browse files Browse the repository at this point in the history
Signed-off-by: Stéphane Galland <galland@arakhne.org>
  • Loading branch information
gallandarakhneorg committed May 12, 2017
1 parent bcb5aec commit fb0c813
Showing 1 changed file with 15 additions and 2 deletions.
Expand Up @@ -56,6 +56,8 @@ public class LifecycleSkill extends BuiltinSkill implements Lifecycle {

private ClearableReference<Skill> skillBufferInternalEventBusCapacity;

private ClearableReference<Skill> skillDefaultContextInteraction;

/**
* Constructs the skill.
*
Expand All @@ -76,6 +78,17 @@ protected final InternalEventBusCapacity getInternalEventBusCapacitySkill() {
return $castSkill(InternalEventBusCapacity.class, this.skillBufferInternalEventBusCapacity);
}

/** Replies the InternalEventBusCapacity skill as fast as possible.
*
* @return the skill
*/
protected final DefaultContextInteractions getDefaultContextInteractionsSkill() {
if (this.skillDefaultContextInteraction == null || this.skillDefaultContextInteraction.get() == null) {
this.skillDefaultContextInteraction = $getSkill(DefaultContextInteractions.class);
}
return $castSkill(DefaultContextInteractions.class, this.skillDefaultContextInteraction);
}

@Override
public int getInstallationOrder() {
if (installationOrder < 0) {
Expand All @@ -89,7 +102,7 @@ public UUID spawn(Class<? extends Agent> agentType, Object... params) {
final List<UUID> ids = this.spawnService.spawn(
1,
getOwner().getID(),
getSkill(DefaultContextInteractions.class).getDefaultContext(),
getDefaultContextInteractionsSkill().getDefaultContext(),
null, agentType, params);
if (ids.isEmpty()) {
return null;
Expand All @@ -101,7 +114,7 @@ public UUID spawn(Class<? extends Agent> agentType, Object... params) {
public Collection<UUID> spawn(int nbAgents, Class<? extends Agent> agentType, Object... params) {
return this.spawnService.spawn(nbAgents,
getOwner().getID(),
getSkill(DefaultContextInteractions.class).getDefaultContext(),
getDefaultContextInteractionsSkill().getDefaultContext(),
null, agentType, params);
}

Expand Down

0 comments on commit fb0c813

Please sign in to comment.