ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/tck/AbstractQueuedSynchronizerTest.java
(Generate patch)

Comparing jsr166/src/test/tck/AbstractQueuedSynchronizerTest.java (file contents):
Revision 1.5 by dl, Tue Dec 30 15:48:38 2003 UTC vs.
Revision 1.6 by dl, Wed Dec 31 21:30:08 2003 UTC

# Line 30 | Line 30 | public class AbstractQueuedSynchronizerT
30       */
31      static class Mutex implements Lock, java.io.Serializable {
32          private static class Sync extends AbstractQueuedSynchronizer {
33 <            public int acquireExclusiveState(boolean isQueued, int acquires) {
33 >            boolean isLocked() { return getState() == 1; }
34 >
35 >            public boolean tryAcquireExclusiveState(boolean isQueued, int acquires) {
36                  assert acquires == 1; // Does not use multiple acquires
37 <                return compareAndSet(0, 1)? 0 : -1;
37 >                return compareAndSetState(0, 1);
38              }
39              
40              public boolean releaseExclusiveState(int releases) {
41 <                set(0);
41 >                setState(0);
42                  return true;
43              }
44              
45              public void checkConditionAccess(Thread thread, boolean waiting) {
46 <                if (get() == 0) throw new IllegalMonitorStateException();
46 >                if (getState() == 0) throw new IllegalMonitorStateException();
47              }
48              
49              Condition newCondition() { return new ConditionObject(); }
50              
51              private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException {
52                  s.defaultReadObject();
53 <                set(0); // reset to unlocked state
53 >                setState(0); // reset to unlocked state
54              }
55          }
56          
57          private final Sync sync = new Sync();
58          public boolean tryLock() {
59 <            return sync.acquireExclusiveState(false, 1) >= 0;
59 >            return sync.tryAcquireExclusiveState(false, 1);
60          }
61          public void lock() {
62              sync.acquireExclusiveUninterruptibly(1);
# Line 67 | Line 69 | public class AbstractQueuedSynchronizerT
69          }
70          public void unlock() { sync.releaseExclusive(1); }
71          public Condition newCondition() { return sync.newCondition(); }
72 <        public boolean isLocked() { return sync.get() != 0; }
72 >        public boolean isLocked() { return sync.isLocked(); }
73          public boolean hasQueuedThreads() { return sync.hasQueuedThreads(); }
74      }
75  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines