01: package soot.jimple.toolkits.thread.transaction;
02:
03: import java.util.*;
04: import soot.*;
05:
06: class TransactionGroup implements Iterable<Transaction> {
07: int groupNum;
08:
09: // Information about the group members
10: List<Transaction> transactions;
11:
12: // Information about the selected lock(s)
13: public boolean isDynamicLock; // is lockObject actually dynamic? or is it a static ref?
14: public boolean useDynamicLock; // use one dynamic lock per tn
15: public Value lockObject;
16: public boolean useLocksets;
17:
18: public TransactionGroup(int groupNum) {
19: this .groupNum = groupNum;
20: this .transactions = new ArrayList<Transaction>();
21:
22: this .isDynamicLock = false;
23: this .useDynamicLock = false;
24: this .lockObject = null;
25: this .useLocksets = false;
26: }
27:
28: public int num() {
29: return groupNum;
30: }
31:
32: public int size() {
33: return transactions.size();
34: }
35:
36: public void add(Transaction tn) {
37: tn.setNumber = groupNum;
38: tn.group = this ;
39: if (!transactions.contains(tn))
40: transactions.add(tn);
41: }
42:
43: public boolean contains(Transaction tn) {
44: return transactions.contains(tn);
45: }
46:
47: public Iterator<Transaction> iterator() {
48: return transactions.iterator();
49: }
50:
51: public void mergeGroups(TransactionGroup other) {
52: if (other == this )
53: return;
54:
55: Iterator<Transaction> tnIt = other.transactions.iterator();
56: while (tnIt.hasNext()) {
57: Transaction tn = tnIt.next();
58: add(tn);
59: }
60: other.transactions.clear();
61: }
62: }
|