Class ClusterLockWrapper

java.lang.Object
com.atlassian.crowd.lock.ClusterLockWrapper

public class ClusterLockWrapper extends Object
Helper class supporting lambdas for ClusterLock
  • Constructor Details

    • ClusterLockWrapper

      public ClusterLockWrapper(Supplier<com.atlassian.beehive.ClusterLock> lockSupplier)
      Parameters:
      lockSupplier - supplier of the lock, under which all operations will be performed
  • Method Details

    • run

      public void run(Runnable runnable)
      Runs provided Runnable under the lock. Blocks to get the lock.
      Parameters:
      runnable - Runnable to be run under the lock
    • run

      public <T> T run(Supplier<T> supplier)
      Runs provided Supplier under the lock. Blocks to get the lock.
      Parameters:
      supplier - Supplier to be run under the lock
      Returns:
      value returned by the supplier
    • tryRun

      public boolean tryRun(Runnable runnable)
      Tries to get the lock and runs provided Runnable under the lock. If the lock wasn't available immediately then does nothing and returns false.
      Parameters:
      runnable - Runnable to be run under the lock
      Returns:
      whether the lock was acquired and Runnable was run