Class GlobalLock

java.lang.Object
org.openremote.container.concurrent.GlobalLock

public class GlobalLock extends Object
  • Field Details

    • lock

      protected static final org.openremote.container.concurrent.GlobalLock.CustomReentrantLock lock
  • Constructor Details

    • GlobalLock

      protected GlobalLock()
  • Method Details

    • getLockTimeoutMillis

      public static int getLockTimeoutMillis()
      Returns:
      Defaults to 10 seconds.
    • withLock

      public static void withLock(String info, Runnable runnable)
      Obtain the lock within getLockTimeoutMillis() or throw IllegalStateException.
      Parameters:
      info - An informal text that is printed in log messages.
      runnable - The guarded code to execute while holding the lock.
    • withLockReturning

      public static <R> R withLockReturning(String info, Supplier<R> supplier)
      Obtain the lock within getLockTimeoutMillis() or throw IllegalStateException.
      Parameters:
      info - An informal text that is printed in log messages.
      supplier - The guarded code to execute while holding the lock.