Skip to content

Commit 3b34cfa

Browse files
author
Bytekeeper
committed
Added BT node for acquiring locks
1 parent 5ec3706 commit 3b34cfa

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package org.bk.ass.bt;
2+
3+
import org.bk.ass.manage.Lock;
4+
5+
public class AcquireLock<T> extends TreeNode {
6+
7+
private final Lock<T> lock;
8+
9+
public AcquireLock(Lock<T> lock) {
10+
this.lock = lock;
11+
}
12+
13+
@Override
14+
public void exec() {
15+
if (lock.acquire()) {
16+
success();
17+
} else {
18+
failed();
19+
}
20+
}
21+
22+
@Override
23+
public void reset() {
24+
super.reset();
25+
lock.reset();
26+
}
27+
}

0 commit comments

Comments
 (0)