Package jetbrains.buildServer.concurrent
Class DeduplicatingExecutor<T>
- java.lang.Object
-
- jetbrains.buildServer.concurrent.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 Summary
Constructors Constructor Description DeduplicatingExecutor(ExecutorService delegate)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ExecutorService
getDelegate()
void
submit(T key, Runnable task)
Submits a new task with the given key.
-
-
-
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 deduplicationtask
- task to run
-
getDelegate
public ExecutorService getDelegate()
-
-