ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/main/java/util/concurrent/CountDownLatch.java
(Generate patch)

Comparing jsr166/src/main/java/util/concurrent/CountDownLatch.java (file contents):
Revision 1.16 by dl, Tue Dec 30 15:47:48 2003 UTC vs.
Revision 1.17 by dl, Wed Dec 31 21:30:00 2003 UTC

# Line 129 | Line 129 | public class CountDownLatch {
129       */
130      private static final class Sync extends AbstractQueuedSynchronizer {
131          Sync(int count) {
132 <            set(count);
132 >            setState(count);
133          }
134          
135 <        public int acquireSharedState(boolean isQueued, int acquires) {
136 <            return get() == 0? 1 : -1;
135 >        int getCount() {
136 >            return getState();
137 >        }
138 >
139 >        public int tryAcquireSharedState(boolean isQueued, int acquires) {
140 >            return getState() == 0? 1 : -1;
141          }
142          
143          public boolean releaseSharedState(int releases) {
144              // Decrement count; signal when transition to zero
145 <            int c;
146 <            while ( (c = get()) > 0 && !compareAndSet(c, c-1))
147 <                ;
148 <            return c == 1;
145 >            for (;;) {
146 >                int c = getState();
147 >                if (c == 0)
148 >                    return false;
149 >                if (compareAndSetState(c, c-1))
150 >                    return c == 1;
151 >            }
152          }
153      }
154  
# Line 255 | Line 262 | public class CountDownLatch {
262       * @return the current count.
263       */
264      public long getCount() {
265 <        return sync.get();
265 >        return sync.getCount();
266      }
267   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines