[cvs] / jsr166 / src / test / tck / AbstractQueuedSynchronizerTest.java Repository:
ViewVC logotype

Diff of /jsr166/src/test/tck/AbstractQueuedSynchronizerTest.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2, Mon Dec 29 01:18:40 2003 UTC revision 1.3, Mon Dec 29 14:19:27 2003 UTC
# Line 30  Line 30 
30       */       */
31      static class Mutex implements Lock, java.io.Serializable {      static class Mutex implements Lock, java.io.Serializable {
32          private static class Sync extends AbstractQueuedSynchronizer {          private static class Sync extends AbstractQueuedSynchronizer {
33              public int acquireExclusiveState(boolean isQueued, int acquires, Thread current) {              public int acquireExclusiveState(boolean isQueued, int acquires) {
34                  assert acquires == 1; // Does not use multiple acquires                  assert acquires == 1; // Does not use multiple acquires
35                  return state().compareAndSet(0, 1)? 0 : -1;                  return state().compareAndSet(0, 1)? 0 : -1;
36              }              }
# Line 40  Line 40 
40                  return true;                  return true;
41              }              }
42    
43              public int acquireSharedState(boolean isQueued, int acquires, Thread current) {              public int acquireSharedState(boolean isQueued, int acquires) {
44                  throw new UnsupportedOperationException();                  throw new UnsupportedOperationException();
45              }              }
46    
# Line 62  Line 62 
62    
63          private final Sync sync = new Sync();          private final Sync sync = new Sync();
64          public boolean tryLock() {          public boolean tryLock() {
65              return sync.acquireExclusiveState(false, 1, null) >= 0;              return sync.acquireExclusiveState(false, 1) >= 0;
66          }          }
67          public void lock() {          public void lock() {
68              if (!tryLock()) sync.acquireExclusiveUninterruptibly(1);              sync.acquireExclusiveUninterruptibly(1);
69          }          }
70          public void lockInterruptibly() throws InterruptedException {          public void lockInterruptibly() throws InterruptedException {
71              sync.acquireExclusiveInterruptibly(1);              sync.acquireExclusiveInterruptibly(1);

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

Doug Lea
ViewVC Help
Powered by ViewVC 1.0.8