From fb0c813f98d87e092a6de54ab4174b20955fa72d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Galland?= Date: Fri, 12 May 2017 13:40:28 +0200 Subject: [PATCH] [sre] Buffering the capacity for faster access. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Galland --- .../janusproject/kernel/bic/LifecycleSkill.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/sre/io.janusproject/io.janusproject.plugin/src/io/janusproject/kernel/bic/LifecycleSkill.java b/sre/io.janusproject/io.janusproject.plugin/src/io/janusproject/kernel/bic/LifecycleSkill.java index bab756887a..150c56ef7a 100644 --- a/sre/io.janusproject/io.janusproject.plugin/src/io/janusproject/kernel/bic/LifecycleSkill.java +++ b/sre/io.janusproject/io.janusproject.plugin/src/io/janusproject/kernel/bic/LifecycleSkill.java @@ -56,6 +56,8 @@ public class LifecycleSkill extends BuiltinSkill implements Lifecycle { private ClearableReference skillBufferInternalEventBusCapacity; + private ClearableReference skillDefaultContextInteraction; + /** * Constructs the skill. * @@ -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) { @@ -89,7 +102,7 @@ public UUID spawn(Class agentType, Object... params) { final List ids = this.spawnService.spawn( 1, getOwner().getID(), - getSkill(DefaultContextInteractions.class).getDefaultContext(), + getDefaultContextInteractionsSkill().getDefaultContext(), null, agentType, params); if (ids.isEmpty()) { return null; @@ -101,7 +114,7 @@ public UUID spawn(Class agentType, Object... params) { public Collection spawn(int nbAgents, Class agentType, Object... params) { return this.spawnService.spawn(nbAgents, getOwner().getID(), - getSkill(DefaultContextInteractions.class).getDefaultContext(), + getDefaultContextInteractionsSkill().getDefaultContext(), null, agentType, params); }