/** * Sets the threadpool size. In 'single mode' the default threadpool size is * determined by {@link #DEFAULT_NUM_THREADS_IN_SINGLE_MODE}. In 'multi * mode' the threadpool size is determined by * {@link Runtime#availableProcessors()}. * @param threads The number of threads, must be positive. * @return This, as per the builder pattern. */ @CheckReturnValue public Builder withThreadPoolSize(int threads) { checkArgument(threads > 0); return create(getMode(), threads, getThreadGrouping()); }
/** * The initial mode of the produced {@link RtSolverModel} will be 'multi'. * See {@link RtSolverModel} for more information. * @return This, as per the builder pattern. */ @CheckReturnValue public Builder withMultiMode() { return create(Mode.MULTI_MODE, getThreadPoolSize(), getThreadGrouping()); }
/** * The initial mode of the produced {@link RtSolverModel} will be 'single'. * See {@link RtSolverModel} for more information. * @return This, as per the builder pattern. */ @CheckReturnValue public Builder withSingleMode() { return create(Mode.SINGLE_MODE, getThreadPoolSize(), getThreadGrouping()); }
@Override public RtSolverModel build(DependencyProvider dependencyProvider) { final RealtimeClockController c = dependencyProvider .get(RealtimeClockController.class); final PDPRoadModel rm = dependencyProvider.get(PDPRoadModel.class); final PDPModel pm = dependencyProvider.get(PDPModel.class); return new RtSolverModel(c, rm, pm, getMode(), getThreadPoolSize(), getThreadGrouping()); }
@Override public boolean equals(Object o) { if (o == this) { return true; } if (o instanceof RtSolverModel.Builder) { RtSolverModel.Builder that = (RtSolverModel.Builder) o; return (this.mode.equals(that.getMode())) && (this.threadPoolSize == that.getThreadPoolSize()) && (this.threadGrouping == that.getThreadGrouping()); } return false; }