panda.task.ReschedulingRunnable Maven / Gradle / Ivy
package panda.task;
import panda.lang.ErrorHandler;
import java.util.Date;
import java.util.concurrent.Delayed;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
/**
* Internal adapter that reschedules an underlying {@link Runnable} according
* to the next execution time suggested by a given {@link Trigger}.
*
* Necessary because a native {@link ScheduledExecutorService} supports
* delay-driven execution only. The flexibility of the {@link Trigger} interface
* will be translated onto a delay for the next execution time (repeatedly).
*
*/
class ReschedulingRunnable extends DelegatingErrorHandlingRunnable implements ScheduledFuture