120 |
|
} |
121 |
|
} |
122 |
|
|
123 |
– |
|
123 |
|
/** |
124 |
|
* Wait for a taker to take item placed by putter, or time out. |
125 |
|
*/ |
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 { |
160 |
|
} |
161 |
|
} |
162 |
|
|
166 |
– |
|
163 |
|
/** |
164 |
|
* Wait for a putter to put item placed by taker, or time out. |
165 |
|
*/ |
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 { |
278 |
|
qlock.unlock(); |
279 |
|
} |
280 |
|
|
281 |
< |
if (mustWait) |
281 |
> |
if (mustWait) |
282 |
|
return (E)node.waitForPut(timed, nanos); |
283 |
|
|
284 |
|
else { |