|
Revision 2649, 3.2 KB
(checked in by mspiegel, 16 months ago)
|
|
[warnings] Removed all unused imports in com.sun.fortress.interpreter.* and children packages.
|
| Line | |
|---|
| 1 | |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | |
|---|
| 16 | |
|---|
| 17 | |
|---|
| 18 | package com.sun.fortress.interpreter.evaluator.transactions; |
|---|
| 19 | import com.sun.fortress.interpreter.evaluator.tasks.FortressTaskRunner; |
|---|
| 20 | import java.util.AbstractSet; |
|---|
| 21 | import java.util.concurrent.CopyOnWriteArrayList; |
|---|
| 22 | |
|---|
| 23 | public class ReadSet extends AbstractSet<Transaction> { |
|---|
| 24 | private CopyOnWriteArrayList<Transaction> elements; |
|---|
| 25 | private Boolean sealed; |
|---|
| 26 | |
|---|
| 27 | public ReadSet() { |
|---|
| 28 | sealed = false; |
|---|
| 29 | elements = new CopyOnWriteArrayList<Transaction>(); |
|---|
| 30 | } |
|---|
| 31 | |
|---|
| 32 | |
|---|
| 33 | public ReadSet(ReadSet r) { |
|---|
| 34 | sealed = false; |
|---|
| 35 | elements = new CopyOnWriteArrayList<Transaction>(); |
|---|
| 36 | |
|---|
| 37 | |
|---|
| 38 | |
|---|
| 39 | myAdd(r); |
|---|
| 40 | } |
|---|
| 41 | |
|---|
| 42 | private void myAdd(ReadSet r) { |
|---|
| 43 | for (Transaction t : elements) |
|---|
| 44 | if (t.isActive()) |
|---|
| 45 | elements.add(t); |
|---|
| 46 | } |
|---|
| 47 | |
|---|
| 48 | public String toString() { |
|---|
| 49 | return "sealed = " + sealed + " elements = " + elements; |
|---|
| 50 | } |
|---|
| 51 | |
|---|
| 52 | |
|---|
| 53 | |
|---|
| 54 | |
|---|
| 55 | |
|---|
| 56 | |
|---|
| 57 | public void copyFrom(ReadSet aSet) { |
|---|
| 58 | elements.addAll(aSet.elements); |
|---|
| 59 | } |
|---|
| 60 | |
|---|
| 61 | public void seal() { |
|---|
| 62 | sealed = true; |
|---|
| 63 | } |
|---|
| 64 | |
|---|
| 65 | |
|---|
| 66 | |
|---|
| 67 | |
|---|
| 68 | |
|---|
| 69 | |
|---|
| 70 | public boolean add(Transaction t) { |
|---|
| 71 | cleanup(); |
|---|
| 72 | if (sealed) { |
|---|
| 73 | FortressTaskRunner.debugPrintln("add of " + t + " to readset " + toString() + " failed because readset was sealed"); |
|---|
| 74 | return false; |
|---|
| 75 | } else { |
|---|
| 76 | elements.addIfAbsent(t); |
|---|
| 77 | return true; |
|---|
| 78 | } |
|---|
| 79 | } |
|---|
| 80 | |
|---|
| 81 | public void cleanup() { |
|---|
| 82 | for (Transaction t : elements) |
|---|
| 83 | if (!t.isActive()) |
|---|
| 84 | remove(t); |
|---|
| 85 | } |
|---|
| 86 | |
|---|
| 87 | |
|---|
| 88 | |
|---|
| 89 | |
|---|
| 90 | |
|---|
| 91 | |
|---|
| 92 | public boolean remove(Transaction t) { |
|---|
| 93 | boolean res = elements.contains(t); |
|---|
| 94 | if (res) elements.remove(t); |
|---|
| 95 | return res; |
|---|
| 96 | } |
|---|
| 97 | |
|---|
| 98 | |
|---|
| 99 | |
|---|
| 100 | |
|---|
| 101 | public void clear() { |
|---|
| 102 | elements.clear(); |
|---|
| 103 | } |
|---|
| 104 | |
|---|
| 105 | |
|---|
| 106 | |
|---|
| 107 | |
|---|
| 108 | |
|---|
| 109 | public int size() { |
|---|
| 110 | return elements.size(); |
|---|
| 111 | } |
|---|
| 112 | |
|---|
| 113 | |
|---|
| 114 | |
|---|
| 115 | |
|---|
| 116 | |
|---|
| 117 | public java.util.Iterator<Transaction> iterator() { |
|---|
| 118 | return elements.iterator(); |
|---|
| 119 | } |
|---|
| 120 | } |
|---|