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

Comparing jsr166/src/main/java/util/concurrent/SynchronousQueue.java (file contents):
Revision 1.38 by dl, Fri Jan 9 14:45:17 2004 UTC vs.
Revision 1.39 by dl, Sun Jan 11 16:02:17 2004 UTC

# Line 95 | Line 95 | public class SynchronousQueue<E> extends
95          /**
96           * Implements AQS base acquire to succeed if not in WAITING state
97           */
98 <        protected boolean tryAcquireExclusive(int ignore) {
98 >        protected boolean tryAcquire(int ignore) {
99              return getState() != 0;
100          }
101  
102          /**
103           * Implements AQS base release to signal if state changed
104           */
105 <        protected boolean tryReleaseExclusive(int newState) {
105 >        protected boolean tryRelease(int newState) {
106              return compareAndSetState(0, newState);
107          }
108  
# Line 121 | Line 121 | public class SynchronousQueue<E> extends
121           */
122          private void checkCancellationOnInterrupt(InterruptedException ie)
123              throws InterruptedException {
124 <            if (releaseExclusive(CANCEL))
124 >            if (release(CANCEL))
125                  throw ie;
126              Thread.currentThread().interrupt();
127          }
# Line 132 | Line 132 | public class SynchronousQueue<E> extends
132           */
133          boolean setItem(Object x) {
134              item = x; // can place in slot even if cancelled
135 <            return releaseExclusive(ACK);
135 >            return release(ACK);
136          }
137  
138          /**
# Line 140 | Line 140 | public class SynchronousQueue<E> extends
140           * to continue.
141           */
142          Object getItem() {
143 <            return (releaseExclusive(ACK))? extract() : null;
143 >            return (release(ACK))? extract() : null;
144          }
145  
146          /**
# Line 148 | Line 148 | public class SynchronousQueue<E> extends
148           */
149          void waitForTake() throws InterruptedException {
150              try {
151 <                acquireExclusiveInterruptibly(0);
151 >                acquireInterruptibly(0);
152              } catch (InterruptedException ie) {
153                  checkCancellationOnInterrupt(ie);
154              }
# Line 159 | Line 159 | public class SynchronousQueue<E> extends
159           */
160          Object waitForPut() throws InterruptedException {
161              try {
162 <                acquireExclusiveInterruptibly(0);
162 >                acquireInterruptibly(0);
163              } catch (InterruptedException ie) {
164                  checkCancellationOnInterrupt(ie);
165              }
# Line 171 | Line 171 | public class SynchronousQueue<E> extends
171           */
172          boolean waitForTake(long nanos) throws InterruptedException {
173              try {
174 <                if (!acquireExclusiveNanos(0, nanos) &&
175 <                    releaseExclusive(CANCEL))
174 >                if (!tryAcquireNanos(0, nanos) &&
175 >                    release(CANCEL))
176                      return false;
177              } catch (InterruptedException ie) {
178                  checkCancellationOnInterrupt(ie);
# Line 185 | Line 185 | public class SynchronousQueue<E> extends
185           */
186          Object waitForPut(long nanos) throws InterruptedException {
187              try {
188 <                if (!acquireExclusiveNanos(0, nanos) &&
189 <                    releaseExclusive(CANCEL))
188 >                if (!tryAcquireNanos(0, nanos) &&
189 >                    release(CANCEL))
190                      return null;
191              } catch (InterruptedException ie) {
192                  checkCancellationOnInterrupt(ie);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines