Package org.somda.sdc.common.util
Class AutoLock
-
- All Implemented Interfaces:
-
java.lang.AutoCloseable,java.util.concurrent.locks.Lock
public class AutoLock<T extends Lock> implements Lock, AutoCloseable
Converts locks to auto-closables.
-
-
Method Summary
Modifier and Type Method Description TgetLock()Returns the wrapped lock instance. static <T extends Lock> AutoLock<T>lock(T lock)Locks the given lock and return auto-closable variant. voidclose()voidlock()voidlockInterruptibly()booleantryLock()booleantryLock(long time, TimeUnit unit)voidunlock()ConditionnewCondition()-
-
Method Detail
-
lock
static <T extends Lock> AutoLock<T> lock(T lock)
Locks the given lock and return auto-closable variant.
- Parameters:
lock- the lock to wrap.- Returns:
an auto-closable instance to be used with
try (...) { ... }.
-
close
void close()
-
lock
void lock()
-
lockInterruptibly
void lockInterruptibly()
-
tryLock
boolean tryLock()
-
unlock
void unlock()
-
newCondition
Condition newCondition()
-
-
-
-