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.1 by dl, Sun Dec 28 21:56:18 2003 UTC vs.
Revision 1.5 by dl, Tue Dec 30 15:48:38 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, Thread current) {
33 >            public int acquireExclusiveState(boolean isQueued, int acquires) {
34                  assert acquires == 1; // Does not use multiple acquires
35 <                return state().compareAndSet(0, 1)? 0 : -1;
35 >                return compareAndSet(0, 1)? 0 : -1;
36              }
37              
38              public boolean releaseExclusiveState(int releases) {
39 <                state().set(0);
39 >                set(0);
40                  return true;
41              }
42              
43            public int acquireSharedState(boolean isQueued, int acquires, Thread current) {
44                throw new UnsupportedOperationException();
45            }
46            
47            public boolean releaseSharedState(int releases) {
48                throw new UnsupportedOperationException();
49            }
50            
43              public void checkConditionAccess(Thread thread, boolean waiting) {
44 <                if (state().get() == 0) throw new IllegalMonitorStateException();
44 >                if (get() == 0) throw new IllegalMonitorStateException();
45              }
46              
47              Condition newCondition() { return new ConditionObject(); }
48              
49              private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException {
50                  s.defaultReadObject();
51 <                state().set(0); // reset to unlocked state
51 >                set(0); // reset to unlocked state
52              }
53          }
54          
55          private final Sync sync = new Sync();
64        public void lock() { sync.acquireExclusiveUninterruptibly(1);  }
56          public boolean tryLock() {
57 <            return sync.acquireExclusiveState(false, 1, null) >= 0;
57 >            return sync.acquireExclusiveState(false, 1) >= 0;
58 >        }
59 >        public void lock() {
60 >            sync.acquireExclusiveUninterruptibly(1);
61          }
62          public void lockInterruptibly() throws InterruptedException {
63              sync.acquireExclusiveInterruptibly(1);
# Line 73 | Line 67 | public class AbstractQueuedSynchronizerT
67          }
68          public void unlock() { sync.releaseExclusive(1); }
69          public Condition newCondition() { return sync.newCondition(); }
70 <        public boolean isLocked() { return sync.state().get() != 0; }
70 >        public boolean isLocked() { return sync.get() != 0; }
71          public boolean hasQueuedThreads() { return sync.hasQueuedThreads(); }
72      }
73  
# Line 117 | Line 111 | public class AbstractQueuedSynchronizerT
111      }
112  
113      /**
114 <     * trylock on an unlocked lock succeeds
114 >     * tryLock on an unlocked lock succeeds
115       */
116      public void testTryLock() {
117          Mutex rl = new Mutex();
# Line 156 | Line 150 | public class AbstractQueuedSynchronizerT
150      }
151  
152      /**
153 <     * timed trylock is interruptible.
153 >     * timed tryLock is interruptible.
154       */
155      public void testInterruptedException2() {
156          final Mutex lock = new Mutex();
# Line 179 | Line 173 | public class AbstractQueuedSynchronizerT
173  
174  
175      /**
176 <     * Trylock on a locked lock fails
176 >     * TryLock on a locked lock fails
177       */
178      public void testTryLockWhenLocked() {
179          final Mutex lock = new Mutex();
# Line 199 | Line 193 | public class AbstractQueuedSynchronizerT
193      }
194  
195      /**
196 <     * Timed trylock on a locked lock times out
196 >     * Timed tryLock on a locked lock times out
197       */
198      public void testTryLock_Timeout() {
199          final Mutex lock = new Mutex();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines