/** * * Schedule a task with a given delay. There is a slight increase in load when using * {@link #submitScheduled(Object, Runnable, long)} over * {@link #schedule(Object, Runnable, long)}. So this should only be used when the future is * necessary. * <p> * The {@link ListenableFuture#get()} method will return {@code null} once the runnable has * completed. * <p> * The key is used to identify this threads execution limit. Tasks with matching keys will be * limited concurrent execution to the level returned by {@link #getMaxConcurrencyPerKey()}. * <p> * See also: {@link SubmitterScheduler#submitScheduled(Runnable, long)} * * @param taskKey Key to use for identifying execution limit * @param task runnable to execute * @param delayInMs time in milliseconds to wait to execute task * @return a future to know when the task has completed */ public ListenableFuture<?> submitScheduled(Object taskKey, Runnable task, long delayInMs) { return submitScheduled(taskKey, task, null, delayInMs); }
/** * * Schedule a task with a given delay. There is a slight increase in load when using * {@link #submitScheduled(Object, Runnable, long)} over * {@link #schedule(Object, Runnable, long)}. So this should only be used when the future is * necessary. * <p> * The {@link ListenableFuture#get()} method will return {@code null} once the runnable has * completed. * <p> * The key is used to identify this threads execution limit. Tasks with matching keys will be * limited concurrent execution to the level returned by {@link #getMaxConcurrencyPerKey()}. * <p> * See also: {@link SubmitterScheduler#submitScheduled(Runnable, long)} * * @param taskKey Key to use for identifying execution limit * @param task runnable to execute * @param delayInMs time in milliseconds to wait to execute task * @return a future to know when the task has completed */ public ListenableFuture<?> submitScheduled(Object taskKey, Runnable task, long delayInMs) { return submitScheduled(taskKey, task, null, delayInMs); }
/** * Schedule a task with a given delay. The {@link ListenableFuture#get()} method will return * the provided result once the runnable has completed. * <p> * The key is used to identify this threads execution limit. Tasks with matching keys will be * limited concurrent execution to the level returned by {@link #getMaxConcurrencyPerKey()}. * <p> * See also: {@link SubmitterScheduler#submitScheduled(Runnable, Object, long)} * * @param <TT> type of result returned from the future * @param taskKey Key to use for identifying execution limit * @param task runnable to execute * @param result result to be returned from resulting future .get() when runnable completes * @param delayInMs time in milliseconds to wait to execute task * @return a future to know when the task has completed */ public <TT> ListenableFuture<TT> submitScheduled(Object taskKey, Runnable task, TT result, long delayInMs) { return submitScheduled(taskKey, RunnableCallableAdapter.adapt(task, result), delayInMs); }
/** * Schedule a task with a given delay. The {@link ListenableFuture#get()} method will return * the provided result once the runnable has completed. * <p> * The key is used to identify this threads execution limit. Tasks with matching keys will be * limited concurrent execution to the level returned by {@link #getMaxConcurrencyPerKey()}. * <p> * See also: {@link SubmitterScheduler#submitScheduled(Runnable, Object, long)} * * @param <TT> type of result returned from the future * @param taskKey Key to use for identifying execution limit * @param task runnable to execute * @param result result to be returned from resulting future .get() when runnable completes * @param delayInMs time in milliseconds to wait to execute task * @return a future to know when the task has completed */ public <TT> ListenableFuture<TT> submitScheduled(Object taskKey, Runnable task, TT result, long delayInMs) { return submitScheduled(taskKey, RunnableCallableAdapter.adapt(task, result), delayInMs); }