mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-02-15 03:35:52 +00:00
Add a 1-liner Locks.checkNotLocked method to make it clearer than writing checkState(!lock.isLocked());
This commit is contained in:
parent
0221b71418
commit
2fb3667c42
@ -20,6 +20,8 @@ import com.google.common.util.concurrent.CycleDetectingLockFactory;
|
||||
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
|
||||
/**
|
||||
* A wrapper around explicit lock creation that lets you control whether bitcoinj performs cycle detection or not.
|
||||
*/
|
||||
@ -59,4 +61,9 @@ public class Locks {
|
||||
public static CycleDetectingLockFactory.Policy getPolicy() {
|
||||
return policy;
|
||||
}
|
||||
|
||||
/** Equivalent to checkState(!lock.isLocked()) but the English description makes it harder to overlook the ! */
|
||||
public static void checkNotLocked(ReentrantLock lock) {
|
||||
checkState(!lock.isLocked());
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user