/** * 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()); }
/** * Sets the thread grouping property. If thread grouping is enabled all * threads spawned by this model will be locked to the same CPU, if it is * disabled each thread will be locked to unique CPU (on a best effort * basis). * @param grouping Indicates whether grouping should be enabled. Default * value is <code>false</code>. * @return This, as per the builder pattern. */ @CheckReturnValue public Builder withThreadGrouping(boolean grouping) { return create(getMode(), getThreadPoolSize(), grouping); }
@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; }
@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()); }