1.RealCall.execute
final class RealCall implements Call {
@Override
public Response execute() throws IOException {
synchronized (this) {
i if (executed) throw new IllegalStateException("Already Executed");
executed = true;
}
transmitter.timeoutEnter();
transmitter.callStart();
try {
client.dispatcher().executed(this); //1.调用Dispatcher的executed
return getResponseWithInterceptorChain();//2调用getResponseWithInterceptorChain
} finally {
client.dispatcher().finished(this); //3.结束
}
}
}
1.1.Dispatcher.executed
将call加入runningSyncCalls
public final class Dispatcher {
private final Deque<RealCall> runningSyncCalls = new ArrayDeque<>();
synchronized void executed(RealCall call) {
runningSyncCalls.add(call);
}
}

本文介绍了RealCall的execute方法,以及Dispatcher如何管理同步请求、InterceptorChain在请求拦截中的作用。请求执行流程包括加入runningSyncCalls,通过InterceptorChain获取响应,最后从队列中移除并可能触发IdleCallback。

754

被折叠的 条评论
为什么被折叠?



