提交 db504079 编写于 作者: K Kohsuke Kawaguchi

documenting why we are doing this.

In JAX San Jose 2011, this was actually consistently observed on Mac
上级 63c65791
......@@ -235,12 +235,15 @@ abstract class Request<RSP extends Serializable,EXC extends Throwable> extends C
public RSP get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
synchronized(Request.this) {
long end = System.currentTimeMillis() + unit.toMillis(timeout);
while(response==null && System.currentTimeMillis()<end) {
// wait until the response arrives
// Note that the wait method can wake up for no reasons at all (AKA spurious wakeup),
long end = System.currentTimeMillis() + unit.toMillis(timeout);
long now;
while(response==null && (now=System.currentTimeMillis())<end) {
if (isCancelled()) {
throw new CancellationException();
}
Request.this.wait(end-System.currentTimeMillis()); // wait until the response arrives
Request.this.wait(Math.max(1,end-now));
}
if(response==null)
throw new TimeoutException();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册