Package io.bdeploy.common
Class TaskSynchronizer
java.lang.Object
io.bdeploy.common.TaskSynchronizer
Performs tasks. When *another* Thread wants to perform the *same* operation, it instead waits for the first Thread to complete
the task.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanisPerforming(Comparable<?> key) <T> Tperform(Comparable<?> key, Callable<T> task) Performs the operation or waits until an existing operation with the same key is done
-
Constructor Details
-
TaskSynchronizer
public TaskSynchronizer()
-
-
Method Details
-
isPerforming
- Parameters:
key- the key to check- Returns:
- whether the given task key is currently associated with a running task.
-
perform
Performs the operation or waits until an existing operation with the same key is done- Parameters:
key- the task key.task- the task to be performed if not already running.
-