Class GlobalLock
java.lang.Object
org.openremote.container.concurrent.GlobalLock
A global reentrant exclusive lock, use convenience methods
withLock(java.lang.String, java.lang.Runnable) and withLockReturning(java.lang.String, java.util.function.Supplier<R>).-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final org.openremote.container.concurrent.GlobalLock.CustomReentrantLock -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intstatic voidObtain the lock withingetLockTimeoutMillis()or throwIllegalStateException.static <R> RwithLockReturning(String info, Supplier<R> supplier) Obtain the lock withingetLockTimeoutMillis()or throwIllegalStateException.
-
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
Obtain the lock withingetLockTimeoutMillis()or throwIllegalStateException.- Parameters:
info- An informal text that is printed in log messages.runnable- The guarded code to execute while holding the lock.
-
withLockReturning
Obtain the lock withingetLockTimeoutMillis()or throwIllegalStateException.- Parameters:
info- An informal text that is printed in log messages.supplier- The guarded code to execute while holding the lock.
-