@Override public void nodeAdded(final Node<T> node) { checkCaller(); if (status != Status.INIT) { for (final Reaction<T> r : node.getReactions()) { scheduleReaction(r); } updateDependenciesForOperationOnNode(env.getNeighborhood(node)); } }
private void newStatus(final Status s) { if (this.compareStatuses(s) > 0) { L.error("Attempt to enter in an illegal status: " + s); } else { schedule(() -> { statusLock.lock(); try { this.status = s; statusCondition.signalAll(); } finally { statusLock.unlock(); } }); } }
@Override public void neighborAdded(final Node<T> node, final Node<T> n) { checkCaller(); dg.addNeighbor(node, n); updateNeighborhood(node); /* * This is necessary, see bug #43 */ updateNeighborhood(n); }
@Override public void run() { synchronized (env) { finalizeConstructor(); status = Status.READY; final long currentThread = Thread.currentThread().getId(); try { while (status.equals(Status.READY)) { idleProcessSingleCommand(); doStep(); idleProcessSingleCommand();
private Queue<Operation> recursiveOperation(final Node<T> origin, final Node<T> destination, final boolean isAdd) { if (isAdd) { Engine.neighborAdded(this, origin, destination); } else { Engine.neighborRemoved(this, origin, destination); } final Neighborhood<T> newNeighborhood = rule.computeNeighborhood(Objects.requireNonNull(destination), this); final Neighborhood<T> oldNeighborhood = neighCache.put(destination.getId(), newNeighborhood); return toQueue(destination, oldNeighborhood, newNeighborhood); }
.map(vars -> () -> { final Environment<T> env = loader.getWith(vars); final Simulation<T> sim = new Engine<>(env, endStep, endTime); outputMonitors.stream().map(Supplier::get).forEach(sim::addOutputMonitor); if (exportFileRoot.isPresent()) {
@Override public void nodeRemoved(final Node<T> node, final Neighborhood<T> oldNeighborhood) { checkCaller(); for (final Reaction<T> r : node.getReactions()) { removeReaction(r); } }
@Override public void nodeMoved(final Node<T> node) { checkCaller(); for (final Reaction<T> r : node.getReactions()) { updateReaction(handlers.get(r)); } }
@Override public Status waitFor(final Status s, final long timeout, final TimeUnit tu) { if (this.compareStatuses(s) > 0) { L.error("Attempt to wait for an illegal status: " + s + " (current state is: " + getStatus() + ")"); } else { statusLock.lock(); try { if (!getStatus().equals(s)) { boolean exit = false; while (!exit) { if (timeout > 0) { final boolean isOnTime = statusCondition.await(timeout, tu); if (!isOnTime || getStatus().equals(s)) { exit = true; if (getStatus().equals(s)) { exit = true; return getStatus();
@Override public synchronized void schedule(final CheckedRunnable r) { if (getStatus().equals(Status.TERMINATED)) { throw new IllegalStateException("This simulation is terminated and can not get resumed."); } commands.add(r); }
@Override public void neighborRemoved(final Node<T> node, final Node<T> n) { checkCaller(); dg.removeNeighbor(node, n); updateNeighborhood(node); updateNeighborhood(n); }
final Neighborhood<T> neighborsNeighborhood = neighCache.get(neighbor.getId()); neighborsNeighborhood.removeNeighbor(node); Engine.neighborRemoved(this, node, neighbor); Engine.neighborAdded(this, node, n);
final Loader loader = generalConfig.getLoader(); final Environment<T, P> env = loader.getWith(config.getVariables()); final Simulation<T, P> sim = new Engine<>(env, generalConfig.getEndStep(), generalConfig.getEndTime()); final Map<String, Object> defaultVars = loader.getVariables().entrySet().stream() .collect(Collectors.toMap(Entry::getKey, e -> e.getValue().getDefault()));