1.RealCall.enqueue
final class RealCall implements Call {
@Override
public void enqueue(Callback responseCallback) {
synchronized (this) {
if (executed) throw new IllegalStateException("Already Executed");
executed = true;
}
transmitter.callStart();
//创建AsyncCall,调用Dispatcher的enqueue
client.dispatcher().enqueue(new AsyncCall(responseCallback));
}
}
2.Dispatcher.enqueue
public final class Dispatcher {
private final Deque<AsyncCall> readyAsyncCalls = new ArrayDeque<>();
void enqueue(AsyncCall call) {
synchronized (this) {
readyAsyncCalls.add(call); //将call添加到readyAsyncCalls
}
promoteAndExecute(); //调用执行的方法
}
}
3.Dispatcher.promoteAndExecute
public final class Dispatcher {
private boolean promoteAndExecute() {
asse