Class TaskSynchronizer

java.lang.Object
io.bdeploy.common.TaskSynchronizer

public class TaskSynchronizer extends Object
Performs tasks. When *another* Thread wants to perform the *same* operation, it instead waits for the first Thread to complete the task.
  • Constructor Details

    • TaskSynchronizer

      public TaskSynchronizer()
  • Method Details

    • isPerforming

      public boolean isPerforming(Comparable<?> key)
      Parameters:
      key - the key to check
      Returns:
      whether the given task key is currently associated with a running task.
    • perform

      public <T> T perform(Comparable<?> key, Callable<T> task)
      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.