adding a test case
[IRC.git] / Robust / TransSim / ObjectInfo.java
1 import java.util.*;
2
3 public class ObjectInfo {
4   FlexScheduler fs;
5   Set waiters;
6   int aborts;
7   int commits;
8   boolean riskyflag;
9
10   public ObjectInfo(FlexScheduler fs) {
11     this.fs=fs;
12     threadowner=-1;
13     this.waiters=new HashSet();
14     if (fs.isLock()&&fs.abortThreshold==0)
15       riskyflag=true;
16   }
17
18   public boolean isRisky() {
19     return riskyflag;
20   }
21
22   public void setRisky(boolean risky) {
23     this.riskyflag=risky;
24   }
25
26   public void recordAbort() {
27     aborts++;
28     if (fs.isLock()&&(aborts>fs.abortThreshold)&&
29         aborts>(commits*fs.abortRatio/100))
30       setRisky(true);
31   }
32
33   public void recordCommit() {
34     commits++;
35   }
36
37   public void addWaiter(FlexScheduler.Event ev) {
38     waiters.add(ev);
39   }
40
41   public Set getWaiters() {
42     return waiters;
43   }
44
45   int threadowner;
46   public void setOwner(int thread) {
47     threadowner=thread;
48   }
49
50   public boolean isOwned() {
51     return threadowner!=-1;
52   }
53
54   public void releaseOwner() {
55     threadowner=-1;
56   }
57
58   public int getOwner() {
59     return threadowner;
60   }
61 }