/** * @param duration that an attempt may persist before being circumvented * @param timeUnit of the 'duration' arg * @param executorService used to enforce time limit * @return an {@link AttemptTimeLimiter} with a fixed time limit for each attempt */ public static AttemptTimeLimiter fixedTimeLimit( long duration, @Nonnull TimeUnit timeUnit, @Nonnull ExecutorService executorService) { Preconditions.checkNotNull(timeUnit); return new FixedAttemptTimeLimit(duration, timeUnit, executorService); }
/** * For control over thread management, it is preferable to offer an {@link ExecutorService} * through the other factory method, {@link #fixedTimeLimit(long, TimeUnit, ExecutorService)}. * All calls to this method use the same cached thread pool created by * {@link Executors#newCachedThreadPool()}. It is unbounded, meaning there is no limit to * the number of threads it will create. It will reuse idle threads if they are available, * and idle threads remain alive for 60 seconds. * * @param duration that an attempt may persist before being circumvented * @param timeUnit of the 'duration' arg * @return an {@link AttemptTimeLimiter} with a fixed time limit for each attempt */ public static AttemptTimeLimiter fixedTimeLimit(long duration, @Nonnull TimeUnit timeUnit) { Preconditions.checkNotNull(timeUnit); return new FixedAttemptTimeLimit(duration, timeUnit); }
/** * For control over thread management, it is preferable to offer an {@link ExecutorService} through the other * factory method, {@link #fixedTimeLimit(long, TimeUnit, ExecutorService)}. See the note on * {@link SimpleTimeLimiter#SimpleTimeLimiter(ExecutorService)}, which this AttemptTimeLimiter uses. * * @param duration that an attempt may persist before being circumvented * @param timeUnit of the 'duration' arg * @param <V> the type of the computation result * @return an {@link AttemptTimeLimiter} with a fixed time limit for each attempt */ public static <V> AttemptTimeLimiter<V> fixedTimeLimit(long duration, @Nonnull TimeUnit timeUnit) { Preconditions.checkNotNull(timeUnit); return new FixedAttemptTimeLimit<V>(duration, timeUnit); }
/** * @param duration that an attempt may persist before being circumvented * @param timeUnit of the 'duration' arg * @param executorService used to enforce time limit * @param <V> the type of the computation result * @return an {@link AttemptTimeLimiter} with a fixed time limit for each attempt */ public static <V> AttemptTimeLimiter<V> fixedTimeLimit(long duration, @Nonnull TimeUnit timeUnit, @Nonnull ExecutorService executorService) { Preconditions.checkNotNull(timeUnit); return new FixedAttemptTimeLimit<V>(duration, timeUnit, executorService); }