Package com.usatiuk.utils
Class DataLocker
java.lang.Object
com.usatiuk.utils.DataLocker
Allows to lock arbitrary keys.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionLocks the data and returns an AutoCloseable that unlocks it when closed.Tries to lock the data and returns an AutoCloseable that unlocks it when closed.
-
Constructor Details
-
DataLocker
public DataLocker()
-
-
Method Details
-
lock
Locks the data and returns an AutoCloseable that unlocks it when closed.- Parameters:
data
- the data to lock- Returns:
- an AutoCloseable that unlocks the data when closed
-
tryLock
Tries to lock the data and returns an AutoCloseable that unlocks it when closed. If the lock is not acquired, returns null.- Parameters:
data
- the data to lock- Returns:
- an AutoCloseable that unlocks the data when closed, or null if the lock was not acquired
-