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.8 by dl, Tue Jul 8 00:46:35 2003 UTC vs.
Revision 1.9 by dl, Sun Jul 13 22:51:51 2003 UTC

# Line 120 | Line 120 | public class SynchronousQueue<E> extends
120              }
121          }
122  
123
123          /**
124           * Wait for a taker to take item placed by putter, or time out.
125           */
# Line 136 | Line 135 | public class SynchronousQueue<E> extends
135                              return false;
136                          }
137                      }
138 <                    try {
139 <                        if (done == null)
140 <                            done = this.newCondition();
141 <                        if (timed)
142 <                            nanos = done.awaitNanos(nanos);
143 <                        else
144 <                            done.await();
145 <                    }
146 <                    catch (InterruptedException ie) {
147 <                        // If taken, return normally but set interrupt status
148 <                        if (item == null) {
149 <                            Thread.currentThread().interrupt();
150 <                            return true;
151 <                        }
152 <                        else {
153 <                            item = CANCELLED;
154 <                            done.signal(); // propagate signal
155 <                            throw ie;
157 <                        }
158 <                    }
138 >                    if (done == null)
139 >                        done = this.newCondition();
140 >                    if (timed)
141 >                        nanos = done.awaitNanos(nanos);
142 >                    else
143 >                        done.await();
144 >                }
145 >            }
146 >            catch (InterruptedException ie) {
147 >                // If taken, return normally but set interrupt status
148 >                if (item == null) {
149 >                    Thread.currentThread().interrupt();
150 >                    return true;
151 >                }
152 >                else {
153 >                    item = CANCELLED;
154 >                    done.signal(); // propagate signal
155 >                    throw ie;
156                  }
157              }
158              finally {
# Line 163 | Line 160 | public class SynchronousQueue<E> extends
160              }
161          }
162  
166
163          /**
164           * Wait for a putter to put item placed by taker, or time out.
165           */
# Line 183 | Line 179 | public class SynchronousQueue<E> extends
179                              return null;
180                          }
181                      }
182 <                    try {
183 <                        if (done == null)
184 <                            done = this.newCondition();
185 <                        if (timed)
186 <                            nanos = done.awaitNanos(nanos);
187 <                        else
188 <                            done.await();
189 <                    }
190 <                    catch (InterruptedException ie) {
191 <                        x = item;
192 <                        if (x != null) {
193 <                            item = null;
194 <                            next = null;
195 <                            Thread.currentThread().interrupt();
196 <                            return x;
197 <                        }
198 <                        else {
199 <                            item = CANCELLED;
200 <                            done.signal(); // propagate signal
201 <                            throw ie;
206 <                        }
207 <                    }
182 >                    if (done == null)
183 >                        done = this.newCondition();
184 >                    if (timed)
185 >                        nanos = done.awaitNanos(nanos);
186 >                    else
187 >                        done.await();
188 >                }
189 >            }
190 >            catch (InterruptedException ie) {
191 >                Object y = item;
192 >                if (y != null) {
193 >                    item = null;
194 >                    next = null;
195 >                    Thread.currentThread().interrupt();
196 >                    return y;
197 >                }
198 >                else {
199 >                    item = CANCELLED;
200 >                    done.signal(); // propagate signal
201 >                    throw ie;
202                  }
203              }
204              finally {
# Line 284 | Line 278 | public class SynchronousQueue<E> extends
278                  qlock.unlock();
279              }
280  
281 <            if (mustWait)
281 >            if (mustWait)
282                  return (E)node.waitForPut(timed, nanos);
283  
284              else {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines