| 44 | public final Map<String, Lock> allLocks = new HashMap<>(); |
| 45 | |
| 46 | private class LockImpl implements Lock { |
| 47 | final Node node; |
| 48 | final String id; |
| 49 | |
| 50 | LockImpl(Node node) { |
| 51 | this.node = node; |
| 52 | this.id = UUID.randomUUID().toString(); |
| 53 | } |
| 54 | |
| 55 | @Override |
| 56 | public void unlock() { |
| 57 | synchronized (LockTree.this) { |
| 58 | if (node.unlock(this)) { |
| 59 | allLocks.remove(id); |
| 60 | } |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | @Override |
| 65 | public String id() { |
| 66 | return id; |
| 67 | } |
| 68 | |
| 69 | @Override |
| 70 | public boolean validateSubpath(int lockLevel, List<String> path) { |
| 71 | return node.validateSubpath(lockLevel, path); |
| 72 | } |
| 73 | |
| 74 | @Override |
| 75 | public String toString() { |
| 76 | return StrUtils.join(node.constructPath(new ArrayDeque<>()), '/'); |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | /** |
| 81 | * This class is used to mark nodes for which acquiring a lock was attempted but didn't succeed. |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…