/** * This progresses tasks based off the time provided. This is primarily used in testing by * providing a possible time in the future (to execute future tasks). This call will NOT block * if no task are currently ready to run. * <p> * This call allows you to specify an {@link ExceptionHandler}. If provided, if any tasks throw * an exception, this will be called to inform them of the exception. This allows you to ensure * that you get a returned task count (meaning if provided, no exceptions except a possible * {@link InterruptedException} can be thrown). If {@code null} is provided for the exception * handler, than any tasks which throw a {@link RuntimeException}, will throw out of this * invocation. * <p> * This call accepts the absolute time in milliseconds. If you want to advance the scheduler a * specific amount of time forward, look at the "advance" call. * * @since 3.2.0 * @param currentTime Absolute time to provide for looking at task run time * @param exceptionHandler Exception handler implementation to call if any tasks throw an * exception, or null to have exceptions thrown out of this call * @return quantity of tasks run in this tick call */ public int tick(long currentTime, ExceptionHandler exceptionHandler) { if (nowInMillis > currentTime) { throw new IllegalArgumentException("Time can not go backwards"); } nowInMillis = currentTime; return scheduler.tick(exceptionHandler); }
/** * This progresses tasks based off the time provided. This is primarily used in testing by * providing a possible time in the future (to execute future tasks). This call will NOT block * if no task are currently ready to run. * <p> * This call allows you to specify an {@link ExceptionHandler}. If provided, if any tasks throw * an exception, this will be called to inform them of the exception. This allows you to ensure * that you get a returned task count (meaning if provided, no exceptions except a possible * {@link InterruptedException} can be thrown). If {@code null} is provided for the exception * handler, than any tasks which throw a {@link RuntimeException}, will throw out of this * invocation. * <p> * This call accepts the absolute time in milliseconds. If you want to advance the scheduler a * specific amount of time forward, look at the "advance" call. * * @since 3.2.0 * @param currentTime Absolute time to provide for looking at task run time * @param exceptionHandler Exception handler implementation to call if any tasks throw an * exception, or null to have exceptions thrown out of this call * @return quantity of tasks run in this tick call */ public int tick(long currentTime, ExceptionHandler exceptionHandler) { if (nowInMillis > currentTime) { throw new IllegalArgumentException("Time can not go backwards"); } nowInMillis = currentTime; return scheduler.tick(exceptionHandler); }