Defer commands to be executed on saveChanges()

@param commands Commands to defer
348218
public void defer(ICommandData[] commands) {
        deferredCommands.addAll(Arrays.asList(commands));
        for (ICommandData command : commands) {
            deferInternal(command);
        }
    }
754795
@CommandHandler
    public void handle(RequestStartTransactionAcceptedCommand command) {
        apply(new RequestStartTransactionAcceptedEvent(command.getChargingStationId(), command.getEvseId(), command.getIdentifyingToken(), command.getIdentityContext()));
    }
776922
protected function invokeCommands(array $commands) {
    foreach ($commands as $key => $value) {
      if (is_numeric($key)) {
        $command = $value;
        $args = [];
      }
      else {
        $command = $key;
        $args = $value;
      }
      $this->invokeCommand($command, $args);
    }
  }
372733
public function add_deferred_commands() {
		$deferred_additions = \WP_CLI::get_deferred_additions();

		foreach ( $deferred_additions as $name => $addition ) {
			\WP_CLI::debug(
				sprintf(
					'Adding deferred command: %s => %s',
					$name,
					json_encode( $addition )
				),
				'bootstrap'
			);

			\WP_CLI::add_command(
				$name,
				$addition['callable'],
				$addition['args']
			);
		}
	}
1291969
def set_commands(self, commands, timeout=None):
        
        self.desired_commands = commands

        target_commands = list(self.desired_commands)
        for process in list(self.processes):
            found = False
            for i in range(len(target_commands)):
                if process["command"] == target_commands[i]:
                    target_commands.pop(i)
                    found = True
                    break

            if not found:
                self.stop_process(process, timeout)

        # What is left are the commands to add
        # TODO: we should only do this once memory conditions allow
        for command in target_commands:
            self.spawn(command)
1196315
public function setCommands(array $commands)
    {
        $names = [];
        foreach ($commands as $command) {
            $names = \array_merge([$command->getName()], $names);
            $names = \array_merge($command->getAliases(), $names);
        }
        $this->commands = $names;
    }
567209
@Weight(value = Weight.Unit.VARIABLE, comment = "Depends on the current call stack depth")
  public static void cancelDeferredActions() {
    final int stackDepth = ThreadUtils.stackDepth();

    final List<Deferred> list = REGISTRY.get();
    final Iterator<Deferred> iterator = list.iterator();

    while (iterator.hasNext()) {
      final Deferred deferred = iterator.next();
      if (deferred.getStackDepth() >= stackDepth) {
        iterator.remove();
      }
    }
    if (list.isEmpty()) {
      REGISTRY.remove();
    }
  }
1326700
def stop(args):
  """"""
  if args.local:
    raise ValueError("Stopping commands locally is not supported (please kill them yourself)")
  jm = setup(args)
  jm.stop_jobs(get_ids(args.job_ids))
289799
public function commands($commands)
    {
        $commands = is_array($commands) ? $commands : func_get_args();

        Artisan::starting(function ($artisan) use ($commands) {
            $artisan->resolveCommands($commands);
        });
    }
65849
private void handleLogin(GwtCommand command, Deferred deferred) {
		final String oldToken = notNull(command.getUserToken());
		if (!afterLoginCommands.containsKey(oldToken)) {
			afterLoginCommands.put(oldToken, new ArrayList<RetryCommand>());
			login(oldToken);
		}
		afterLogin(command, deferred);
	}
339354
protected void configureIfNecessary(AbstractCommand command) {

		Assert.notNull(command, "command");

		if (getCommandConfigurer() != null) {
			if (!command.isFaceConfigured()) {
                getCommandConfigurer().configure(command);
			}
		}

	}
1319888
@Override
    public void execute(final ReplaceInList command) {
        referenceKeeper.cleanReferenceCache();
        if (couldBeExecuted(command)) {
            executor.execute(command);
        } else {
            keepReferenceIfObservable(command.getValue());
        }
    }
233457
private synchronized void submit(final String command) {
    LOG.log(Level.INFO, "Submit command {0} to {1} evaluators. state: {2}",
        new Object[]{command, this.contexts.size(), this.state});
    assert this.state == State.READY;
    this.expectCount = this.contexts.size();
    this.state = State.WAIT_TASKS;
    this.cmd = null;
    for (final ActiveContext context : this.contexts.values()) {
      this.submit(context, command);
    }
  }
956970
function defer(fn)
{
  var nextTick = typeof setImmediate == 'function'
    ? setImmediate
    : (
      typeof process == 'object' && typeof process.nextTick == 'function'
      ? process.nextTick
      : null
    );

  if (nextTick)
  {
    nextTick(fn);
  }
  else
  {
    setTimeout(fn, 0);
  }
}
618195
public void doBack(String command)
	{
		if (command != null)
			if (command.startsWith("#"))
				command = command.substring(1);
		String javaCommand = this.popHistory(2, false);		// Current command
		Util.getLogger().info("Browser back: java command=" + javaCommand + "  browser command=" + command);
		if (javaCommand == null)
			javaCommand = command;
		if ((javaCommand == null) || (javaCommand.length() == 0))
			javaCommand = this.getInitialCommand(false);
		javaCommand = this.cleanCommand(javaCommand);
		javaCommand = UrlUtil.addURLParam(javaCommand, Params.APPLET, this.getClass().getName());
		Util.getLogger().info("doBack " + javaCommand);
		BaseApplet.handleAction(javaCommand, this, this, Constants.DONT_PUSH_TO_BROWSER);
	}
945546
function doOperation(operation) {
        if (operation.ops.length > 0) {
            try {
                $(exports).triggerHandler('beforeExecuteOperation', [operation]);
                _applyOperation(operation);
                if (operation.bypass !== true) {
                    _undoStack.push(operation);
                    _redoStack.clear();
                    $(exports).triggerHandler('operationExecuted', [operation]);
                }
            } catch (err) {
                console.error(err);
            }
        }
    }
679047
function defer(cb) {
    if (storage.LATENCY === 0 && typeof process !== 'undefined') {
      process.nextTick(cb);
    } else {
      setTimeout(cb, storage.LATENCY);
    }
  }