Class DeduplicatingExecutor<T>

  • Type Parameters:
    T - type of the key for a task

    public class DeduplicatingExecutor<T>
    extends Object
    Ensures that only one task is queued for the given key. Key should implement equals() and hashCode().
    • Constructor Detail

      • DeduplicatingExecutor

        public DeduplicatingExecutor​(@NotNull
                                     ExecutorService delegate)
    • Method Detail

      • submit

        public void submit​(@NotNull
                           T key,
                           @NotNull
                           Runnable task)
        Submits a new task with the given key. If some task with the same key was queued before and is not started yet, then such previous task will be replaced with the new one and only the new one will be executed.
        Parameters:
        key - task's key to perform deduplication
        task - task to run