Dispatcher.smali 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955
  1. .class public final Lokhttp3/Dispatcher;
  2. .super Ljava/lang/Object;
  3. .source ""
  4. # instance fields
  5. .field private executorService:Ljava/util/concurrent/ExecutorService;
  6. .field private idleCallback:Ljava/lang/Runnable;
  7. .field private maxRequests:I
  8. .field private maxRequestsPerHost:I
  9. .field private final readyAsyncCalls:Ljava/util/Deque;
  10. .annotation system Ldalvik/annotation/Signature;
  11. value = {
  12. "Ljava/util/Deque<",
  13. "Lokhttp3/RealCall$AsyncCall;",
  14. ">;"
  15. }
  16. .end annotation
  17. .end field
  18. .field private final runningAsyncCalls:Ljava/util/Deque;
  19. .annotation system Ldalvik/annotation/Signature;
  20. value = {
  21. "Ljava/util/Deque<",
  22. "Lokhttp3/RealCall$AsyncCall;",
  23. ">;"
  24. }
  25. .end annotation
  26. .end field
  27. .field private final runningSyncCalls:Ljava/util/Deque;
  28. .annotation system Ldalvik/annotation/Signature;
  29. value = {
  30. "Ljava/util/Deque<",
  31. "Lokhttp3/RealCall;",
  32. ">;"
  33. }
  34. .end annotation
  35. .end field
  36. # direct methods
  37. .method public constructor <init>()V
  38. .locals 1
  39. invoke-direct {p0}, Ljava/lang/Object;-><init>()V
  40. const/16 v0, 0x40
  41. iput v0, p0, Lokhttp3/Dispatcher;->maxRequests:I
  42. const/4 v0, 0x5
  43. iput v0, p0, Lokhttp3/Dispatcher;->maxRequestsPerHost:I
  44. new-instance v0, Ljava/util/ArrayDeque;
  45. invoke-direct {v0}, Ljava/util/ArrayDeque;-><init>()V
  46. iput-object v0, p0, Lokhttp3/Dispatcher;->readyAsyncCalls:Ljava/util/Deque;
  47. new-instance v0, Ljava/util/ArrayDeque;
  48. invoke-direct {v0}, Ljava/util/ArrayDeque;-><init>()V
  49. iput-object v0, p0, Lokhttp3/Dispatcher;->runningAsyncCalls:Ljava/util/Deque;
  50. new-instance v0, Ljava/util/ArrayDeque;
  51. invoke-direct {v0}, Ljava/util/ArrayDeque;-><init>()V
  52. iput-object v0, p0, Lokhttp3/Dispatcher;->runningSyncCalls:Ljava/util/Deque;
  53. return-void
  54. .end method
  55. .method public constructor <init>(Ljava/util/concurrent/ExecutorService;)V
  56. .locals 1
  57. invoke-direct {p0}, Ljava/lang/Object;-><init>()V
  58. const/16 v0, 0x40
  59. iput v0, p0, Lokhttp3/Dispatcher;->maxRequests:I
  60. const/4 v0, 0x5
  61. iput v0, p0, Lokhttp3/Dispatcher;->maxRequestsPerHost:I
  62. new-instance v0, Ljava/util/ArrayDeque;
  63. invoke-direct {v0}, Ljava/util/ArrayDeque;-><init>()V
  64. iput-object v0, p0, Lokhttp3/Dispatcher;->readyAsyncCalls:Ljava/util/Deque;
  65. new-instance v0, Ljava/util/ArrayDeque;
  66. invoke-direct {v0}, Ljava/util/ArrayDeque;-><init>()V
  67. iput-object v0, p0, Lokhttp3/Dispatcher;->runningAsyncCalls:Ljava/util/Deque;
  68. new-instance v0, Ljava/util/ArrayDeque;
  69. invoke-direct {v0}, Ljava/util/ArrayDeque;-><init>()V
  70. iput-object v0, p0, Lokhttp3/Dispatcher;->runningSyncCalls:Ljava/util/Deque;
  71. iput-object p1, p0, Lokhttp3/Dispatcher;->executorService:Ljava/util/concurrent/ExecutorService;
  72. return-void
  73. .end method
  74. .method private finished(Ljava/util/Deque;Ljava/lang/Object;Z)V
  75. .locals 0
  76. .annotation system Ldalvik/annotation/Signature;
  77. value = {
  78. "<T:",
  79. "Ljava/lang/Object;",
  80. ">(",
  81. "Ljava/util/Deque<",
  82. "TT;>;TT;Z)V"
  83. }
  84. .end annotation
  85. monitor-enter p0
  86. :try_start_0
  87. invoke-interface {p1, p2}, Ljava/util/Deque;->remove(Ljava/lang/Object;)Z
  88. move-result p1
  89. if-eqz p1, :cond_2
  90. if-eqz p3, :cond_0
  91. invoke-direct {p0}, Lokhttp3/Dispatcher;->promoteCalls()V
  92. :cond_0
  93. invoke-virtual {p0}, Lokhttp3/Dispatcher;->runningCallsCount()I
  94. move-result p1
  95. iget-object p2, p0, Lokhttp3/Dispatcher;->idleCallback:Ljava/lang/Runnable;
  96. monitor-exit p0
  97. :try_end_0
  98. .catchall {:try_start_0 .. :try_end_0} :catchall_0
  99. if-nez p1, :cond_1
  100. if-eqz p2, :cond_1
  101. invoke-interface {p2}, Ljava/lang/Runnable;->run()V
  102. :cond_1
  103. return-void
  104. :cond_2
  105. :try_start_1
  106. new-instance p1, Ljava/lang/AssertionError;
  107. const-string p2, "Call wasn\'t in-flight!"
  108. invoke-direct {p1, p2}, Ljava/lang/AssertionError;-><init>(Ljava/lang/Object;)V
  109. throw p1
  110. :catchall_0
  111. move-exception p1
  112. monitor-exit p0
  113. :try_end_1
  114. .catchall {:try_start_1 .. :try_end_1} :catchall_0
  115. throw p1
  116. .end method
  117. .method private promoteCalls()V
  118. .locals 4
  119. iget-object v0, p0, Lokhttp3/Dispatcher;->runningAsyncCalls:Ljava/util/Deque;
  120. invoke-interface {v0}, Ljava/util/Deque;->size()I
  121. move-result v0
  122. iget v1, p0, Lokhttp3/Dispatcher;->maxRequests:I
  123. if-lt v0, v1, :cond_0
  124. return-void
  125. :cond_0
  126. iget-object v0, p0, Lokhttp3/Dispatcher;->readyAsyncCalls:Ljava/util/Deque;
  127. invoke-interface {v0}, Ljava/util/Deque;->isEmpty()Z
  128. move-result v0
  129. if-eqz v0, :cond_1
  130. return-void
  131. :cond_1
  132. iget-object v0, p0, Lokhttp3/Dispatcher;->readyAsyncCalls:Ljava/util/Deque;
  133. invoke-interface {v0}, Ljava/util/Deque;->iterator()Ljava/util/Iterator;
  134. move-result-object v0
  135. :cond_2
  136. invoke-interface {v0}, Ljava/util/Iterator;->hasNext()Z
  137. move-result v1
  138. if-eqz v1, :cond_4
  139. invoke-interface {v0}, Ljava/util/Iterator;->next()Ljava/lang/Object;
  140. move-result-object v1
  141. check-cast v1, Lokhttp3/RealCall$AsyncCall;
  142. invoke-direct {p0, v1}, Lokhttp3/Dispatcher;->runningCallsForHost(Lokhttp3/RealCall$AsyncCall;)I
  143. move-result v2
  144. iget v3, p0, Lokhttp3/Dispatcher;->maxRequestsPerHost:I
  145. if-ge v2, v3, :cond_3
  146. invoke-interface {v0}, Ljava/util/Iterator;->remove()V
  147. iget-object v2, p0, Lokhttp3/Dispatcher;->runningAsyncCalls:Ljava/util/Deque;
  148. invoke-interface {v2, v1}, Ljava/util/Deque;->add(Ljava/lang/Object;)Z
  149. invoke-virtual {p0}, Lokhttp3/Dispatcher;->executorService()Ljava/util/concurrent/ExecutorService;
  150. move-result-object v2
  151. invoke-interface {v2, v1}, Ljava/util/concurrent/ExecutorService;->execute(Ljava/lang/Runnable;)V
  152. :cond_3
  153. iget-object v1, p0, Lokhttp3/Dispatcher;->runningAsyncCalls:Ljava/util/Deque;
  154. invoke-interface {v1}, Ljava/util/Deque;->size()I
  155. move-result v1
  156. iget v2, p0, Lokhttp3/Dispatcher;->maxRequests:I
  157. if-lt v1, v2, :cond_2
  158. :cond_4
  159. return-void
  160. .end method
  161. .method private runningCallsForHost(Lokhttp3/RealCall$AsyncCall;)I
  162. .locals 4
  163. iget-object v0, p0, Lokhttp3/Dispatcher;->runningAsyncCalls:Ljava/util/Deque;
  164. invoke-interface {v0}, Ljava/util/Deque;->iterator()Ljava/util/Iterator;
  165. move-result-object v0
  166. const/4 v1, 0x0
  167. :cond_0
  168. :goto_0
  169. invoke-interface {v0}, Ljava/util/Iterator;->hasNext()Z
  170. move-result v2
  171. if-eqz v2, :cond_1
  172. invoke-interface {v0}, Ljava/util/Iterator;->next()Ljava/lang/Object;
  173. move-result-object v2
  174. check-cast v2, Lokhttp3/RealCall$AsyncCall;
  175. invoke-virtual {v2}, Lokhttp3/RealCall$AsyncCall;->host()Ljava/lang/String;
  176. move-result-object v2
  177. invoke-virtual {p1}, Lokhttp3/RealCall$AsyncCall;->host()Ljava/lang/String;
  178. move-result-object v3
  179. invoke-virtual {v2, v3}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z
  180. move-result v2
  181. if-eqz v2, :cond_0
  182. add-int/lit8 v1, v1, 0x1
  183. goto :goto_0
  184. :cond_1
  185. return v1
  186. .end method
  187. # virtual methods
  188. .method public declared-synchronized cancelAll()V
  189. .locals 2
  190. monitor-enter p0
  191. :try_start_0
  192. iget-object v0, p0, Lokhttp3/Dispatcher;->readyAsyncCalls:Ljava/util/Deque;
  193. invoke-interface {v0}, Ljava/util/Deque;->iterator()Ljava/util/Iterator;
  194. move-result-object v0
  195. :goto_0
  196. invoke-interface {v0}, Ljava/util/Iterator;->hasNext()Z
  197. move-result v1
  198. if-eqz v1, :cond_0
  199. invoke-interface {v0}, Ljava/util/Iterator;->next()Ljava/lang/Object;
  200. move-result-object v1
  201. check-cast v1, Lokhttp3/RealCall$AsyncCall;
  202. invoke-virtual {v1}, Lokhttp3/RealCall$AsyncCall;->get()Lokhttp3/RealCall;
  203. move-result-object v1
  204. invoke-virtual {v1}, Lokhttp3/RealCall;->cancel()V
  205. goto :goto_0
  206. :cond_0
  207. iget-object v0, p0, Lokhttp3/Dispatcher;->runningAsyncCalls:Ljava/util/Deque;
  208. invoke-interface {v0}, Ljava/util/Deque;->iterator()Ljava/util/Iterator;
  209. move-result-object v0
  210. :goto_1
  211. invoke-interface {v0}, Ljava/util/Iterator;->hasNext()Z
  212. move-result v1
  213. if-eqz v1, :cond_1
  214. invoke-interface {v0}, Ljava/util/Iterator;->next()Ljava/lang/Object;
  215. move-result-object v1
  216. check-cast v1, Lokhttp3/RealCall$AsyncCall;
  217. invoke-virtual {v1}, Lokhttp3/RealCall$AsyncCall;->get()Lokhttp3/RealCall;
  218. move-result-object v1
  219. invoke-virtual {v1}, Lokhttp3/RealCall;->cancel()V
  220. goto :goto_1
  221. :cond_1
  222. iget-object v0, p0, Lokhttp3/Dispatcher;->runningSyncCalls:Ljava/util/Deque;
  223. invoke-interface {v0}, Ljava/util/Deque;->iterator()Ljava/util/Iterator;
  224. move-result-object v0
  225. :goto_2
  226. invoke-interface {v0}, Ljava/util/Iterator;->hasNext()Z
  227. move-result v1
  228. if-eqz v1, :cond_2
  229. invoke-interface {v0}, Ljava/util/Iterator;->next()Ljava/lang/Object;
  230. move-result-object v1
  231. check-cast v1, Lokhttp3/RealCall;
  232. invoke-virtual {v1}, Lokhttp3/RealCall;->cancel()V
  233. :try_end_0
  234. .catchall {:try_start_0 .. :try_end_0} :catchall_0
  235. goto :goto_2
  236. :cond_2
  237. monitor-exit p0
  238. return-void
  239. :catchall_0
  240. move-exception v0
  241. monitor-exit p0
  242. goto :goto_4
  243. :goto_3
  244. throw v0
  245. :goto_4
  246. goto :goto_3
  247. .end method
  248. .method declared-synchronized enqueue(Lokhttp3/RealCall$AsyncCall;)V
  249. .locals 2
  250. monitor-enter p0
  251. :try_start_0
  252. iget-object v0, p0, Lokhttp3/Dispatcher;->runningAsyncCalls:Ljava/util/Deque;
  253. invoke-interface {v0}, Ljava/util/Deque;->size()I
  254. move-result v0
  255. iget v1, p0, Lokhttp3/Dispatcher;->maxRequests:I
  256. if-ge v0, v1, :cond_0
  257. invoke-direct {p0, p1}, Lokhttp3/Dispatcher;->runningCallsForHost(Lokhttp3/RealCall$AsyncCall;)I
  258. move-result v0
  259. iget v1, p0, Lokhttp3/Dispatcher;->maxRequestsPerHost:I
  260. if-ge v0, v1, :cond_0
  261. iget-object v0, p0, Lokhttp3/Dispatcher;->runningAsyncCalls:Ljava/util/Deque;
  262. invoke-interface {v0, p1}, Ljava/util/Deque;->add(Ljava/lang/Object;)Z
  263. invoke-virtual {p0}, Lokhttp3/Dispatcher;->executorService()Ljava/util/concurrent/ExecutorService;
  264. move-result-object v0
  265. invoke-interface {v0, p1}, Ljava/util/concurrent/ExecutorService;->execute(Ljava/lang/Runnable;)V
  266. goto :goto_0
  267. :cond_0
  268. iget-object v0, p0, Lokhttp3/Dispatcher;->readyAsyncCalls:Ljava/util/Deque;
  269. invoke-interface {v0, p1}, Ljava/util/Deque;->add(Ljava/lang/Object;)Z
  270. :try_end_0
  271. .catchall {:try_start_0 .. :try_end_0} :catchall_0
  272. :goto_0
  273. monitor-exit p0
  274. return-void
  275. :catchall_0
  276. move-exception p1
  277. monitor-exit p0
  278. throw p1
  279. .end method
  280. .method declared-synchronized executed(Lokhttp3/RealCall;)V
  281. .locals 1
  282. monitor-enter p0
  283. :try_start_0
  284. iget-object v0, p0, Lokhttp3/Dispatcher;->runningSyncCalls:Ljava/util/Deque;
  285. invoke-interface {v0, p1}, Ljava/util/Deque;->add(Ljava/lang/Object;)Z
  286. :try_end_0
  287. .catchall {:try_start_0 .. :try_end_0} :catchall_0
  288. monitor-exit p0
  289. return-void
  290. :catchall_0
  291. move-exception p1
  292. monitor-exit p0
  293. throw p1
  294. .end method
  295. .method public declared-synchronized executorService()Ljava/util/concurrent/ExecutorService;
  296. .locals 9
  297. monitor-enter p0
  298. :try_start_0
  299. iget-object v0, p0, Lokhttp3/Dispatcher;->executorService:Ljava/util/concurrent/ExecutorService;
  300. if-nez v0, :cond_0
  301. new-instance v0, Ljava/util/concurrent/ThreadPoolExecutor;
  302. const/4 v2, 0x0
  303. const v3, 0x7fffffff
  304. const-wide/16 v4, 0x3c
  305. sget-object v6, Ljava/util/concurrent/TimeUnit;->SECONDS:Ljava/util/concurrent/TimeUnit;
  306. new-instance v7, Ljava/util/concurrent/SynchronousQueue;
  307. invoke-direct {v7}, Ljava/util/concurrent/SynchronousQueue;-><init>()V
  308. const-string v1, "OkHttp Dispatcher"
  309. const/4 v8, 0x0
  310. invoke-static {v1, v8}, Lokhttp3/internal/Util;->threadFactory(Ljava/lang/String;Z)Ljava/util/concurrent/ThreadFactory;
  311. move-result-object v8
  312. move-object v1, v0
  313. invoke-direct/range {v1 .. v8}, Ljava/util/concurrent/ThreadPoolExecutor;-><init>(IIJLjava/util/concurrent/TimeUnit;Ljava/util/concurrent/BlockingQueue;Ljava/util/concurrent/ThreadFactory;)V
  314. iput-object v0, p0, Lokhttp3/Dispatcher;->executorService:Ljava/util/concurrent/ExecutorService;
  315. :cond_0
  316. iget-object v0, p0, Lokhttp3/Dispatcher;->executorService:Ljava/util/concurrent/ExecutorService;
  317. :try_end_0
  318. .catchall {:try_start_0 .. :try_end_0} :catchall_0
  319. monitor-exit p0
  320. return-object v0
  321. :catchall_0
  322. move-exception v0
  323. monitor-exit p0
  324. throw v0
  325. .end method
  326. .method finished(Lokhttp3/RealCall$AsyncCall;)V
  327. .locals 2
  328. iget-object v0, p0, Lokhttp3/Dispatcher;->runningAsyncCalls:Ljava/util/Deque;
  329. const/4 v1, 0x1
  330. invoke-direct {p0, v0, p1, v1}, Lokhttp3/Dispatcher;->finished(Ljava/util/Deque;Ljava/lang/Object;Z)V
  331. return-void
  332. .end method
  333. .method finished(Lokhttp3/RealCall;)V
  334. .locals 2
  335. iget-object v0, p0, Lokhttp3/Dispatcher;->runningSyncCalls:Ljava/util/Deque;
  336. const/4 v1, 0x0
  337. invoke-direct {p0, v0, p1, v1}, Lokhttp3/Dispatcher;->finished(Ljava/util/Deque;Ljava/lang/Object;Z)V
  338. return-void
  339. .end method
  340. .method public declared-synchronized getMaxRequests()I
  341. .locals 1
  342. monitor-enter p0
  343. :try_start_0
  344. iget v0, p0, Lokhttp3/Dispatcher;->maxRequests:I
  345. :try_end_0
  346. .catchall {:try_start_0 .. :try_end_0} :catchall_0
  347. monitor-exit p0
  348. return v0
  349. :catchall_0
  350. move-exception v0
  351. monitor-exit p0
  352. throw v0
  353. .end method
  354. .method public declared-synchronized getMaxRequestsPerHost()I
  355. .locals 1
  356. monitor-enter p0
  357. :try_start_0
  358. iget v0, p0, Lokhttp3/Dispatcher;->maxRequestsPerHost:I
  359. :try_end_0
  360. .catchall {:try_start_0 .. :try_end_0} :catchall_0
  361. monitor-exit p0
  362. return v0
  363. :catchall_0
  364. move-exception v0
  365. monitor-exit p0
  366. throw v0
  367. .end method
  368. .method public declared-synchronized queuedCalls()Ljava/util/List;
  369. .locals 3
  370. .annotation system Ldalvik/annotation/Signature;
  371. value = {
  372. "()",
  373. "Ljava/util/List<",
  374. "Lokhttp3/Call;",
  375. ">;"
  376. }
  377. .end annotation
  378. monitor-enter p0
  379. :try_start_0
  380. new-instance v0, Ljava/util/ArrayList;
  381. invoke-direct {v0}, Ljava/util/ArrayList;-><init>()V
  382. iget-object v1, p0, Lokhttp3/Dispatcher;->readyAsyncCalls:Ljava/util/Deque;
  383. invoke-interface {v1}, Ljava/util/Deque;->iterator()Ljava/util/Iterator;
  384. move-result-object v1
  385. :goto_0
  386. invoke-interface {v1}, Ljava/util/Iterator;->hasNext()Z
  387. move-result v2
  388. if-eqz v2, :cond_0
  389. invoke-interface {v1}, Ljava/util/Iterator;->next()Ljava/lang/Object;
  390. move-result-object v2
  391. check-cast v2, Lokhttp3/RealCall$AsyncCall;
  392. invoke-virtual {v2}, Lokhttp3/RealCall$AsyncCall;->get()Lokhttp3/RealCall;
  393. move-result-object v2
  394. invoke-interface {v0, v2}, Ljava/util/List;->add(Ljava/lang/Object;)Z
  395. goto :goto_0
  396. :cond_0
  397. invoke-static {v0}, Ljava/util/Collections;->unmodifiableList(Ljava/util/List;)Ljava/util/List;
  398. move-result-object v0
  399. :try_end_0
  400. .catchall {:try_start_0 .. :try_end_0} :catchall_0
  401. monitor-exit p0
  402. return-object v0
  403. :catchall_0
  404. move-exception v0
  405. monitor-exit p0
  406. goto :goto_2
  407. :goto_1
  408. throw v0
  409. :goto_2
  410. goto :goto_1
  411. .end method
  412. .method public declared-synchronized queuedCallsCount()I
  413. .locals 1
  414. monitor-enter p0
  415. :try_start_0
  416. iget-object v0, p0, Lokhttp3/Dispatcher;->readyAsyncCalls:Ljava/util/Deque;
  417. invoke-interface {v0}, Ljava/util/Deque;->size()I
  418. move-result v0
  419. :try_end_0
  420. .catchall {:try_start_0 .. :try_end_0} :catchall_0
  421. monitor-exit p0
  422. return v0
  423. :catchall_0
  424. move-exception v0
  425. monitor-exit p0
  426. throw v0
  427. .end method
  428. .method public declared-synchronized runningCalls()Ljava/util/List;
  429. .locals 3
  430. .annotation system Ldalvik/annotation/Signature;
  431. value = {
  432. "()",
  433. "Ljava/util/List<",
  434. "Lokhttp3/Call;",
  435. ">;"
  436. }
  437. .end annotation
  438. monitor-enter p0
  439. :try_start_0
  440. new-instance v0, Ljava/util/ArrayList;
  441. invoke-direct {v0}, Ljava/util/ArrayList;-><init>()V
  442. iget-object v1, p0, Lokhttp3/Dispatcher;->runningSyncCalls:Ljava/util/Deque;
  443. invoke-interface {v0, v1}, Ljava/util/List;->addAll(Ljava/util/Collection;)Z
  444. iget-object v1, p0, Lokhttp3/Dispatcher;->runningAsyncCalls:Ljava/util/Deque;
  445. invoke-interface {v1}, Ljava/util/Deque;->iterator()Ljava/util/Iterator;
  446. move-result-object v1
  447. :goto_0
  448. invoke-interface {v1}, Ljava/util/Iterator;->hasNext()Z
  449. move-result v2
  450. if-eqz v2, :cond_0
  451. invoke-interface {v1}, Ljava/util/Iterator;->next()Ljava/lang/Object;
  452. move-result-object v2
  453. check-cast v2, Lokhttp3/RealCall$AsyncCall;
  454. invoke-virtual {v2}, Lokhttp3/RealCall$AsyncCall;->get()Lokhttp3/RealCall;
  455. move-result-object v2
  456. invoke-interface {v0, v2}, Ljava/util/List;->add(Ljava/lang/Object;)Z
  457. goto :goto_0
  458. :cond_0
  459. invoke-static {v0}, Ljava/util/Collections;->unmodifiableList(Ljava/util/List;)Ljava/util/List;
  460. move-result-object v0
  461. :try_end_0
  462. .catchall {:try_start_0 .. :try_end_0} :catchall_0
  463. monitor-exit p0
  464. return-object v0
  465. :catchall_0
  466. move-exception v0
  467. monitor-exit p0
  468. goto :goto_2
  469. :goto_1
  470. throw v0
  471. :goto_2
  472. goto :goto_1
  473. .end method
  474. .method public declared-synchronized runningCallsCount()I
  475. .locals 2
  476. monitor-enter p0
  477. :try_start_0
  478. iget-object v0, p0, Lokhttp3/Dispatcher;->runningAsyncCalls:Ljava/util/Deque;
  479. invoke-interface {v0}, Ljava/util/Deque;->size()I
  480. move-result v0
  481. iget-object v1, p0, Lokhttp3/Dispatcher;->runningSyncCalls:Ljava/util/Deque;
  482. invoke-interface {v1}, Ljava/util/Deque;->size()I
  483. move-result v1
  484. :try_end_0
  485. .catchall {:try_start_0 .. :try_end_0} :catchall_0
  486. add-int/2addr v0, v1
  487. monitor-exit p0
  488. return v0
  489. :catchall_0
  490. move-exception v0
  491. monitor-exit p0
  492. throw v0
  493. .end method
  494. .method public declared-synchronized setIdleCallback(Ljava/lang/Runnable;)V
  495. .locals 0
  496. monitor-enter p0
  497. :try_start_0
  498. iput-object p1, p0, Lokhttp3/Dispatcher;->idleCallback:Ljava/lang/Runnable;
  499. :try_end_0
  500. .catchall {:try_start_0 .. :try_end_0} :catchall_0
  501. monitor-exit p0
  502. return-void
  503. :catchall_0
  504. move-exception p1
  505. monitor-exit p0
  506. throw p1
  507. .end method
  508. .method public declared-synchronized setMaxRequests(I)V
  509. .locals 3
  510. monitor-enter p0
  511. const/4 v0, 0x1
  512. if-lt p1, v0, :cond_0
  513. :try_start_0
  514. iput p1, p0, Lokhttp3/Dispatcher;->maxRequests:I
  515. invoke-direct {p0}, Lokhttp3/Dispatcher;->promoteCalls()V
  516. :try_end_0
  517. .catchall {:try_start_0 .. :try_end_0} :catchall_0
  518. monitor-exit p0
  519. return-void
  520. :catchall_0
  521. move-exception p1
  522. goto :goto_0
  523. :cond_0
  524. :try_start_1
  525. new-instance v0, Ljava/lang/IllegalArgumentException;
  526. new-instance v1, Ljava/lang/StringBuilder;
  527. invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V
  528. const-string v2, "max < 1: "
  529. invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  530. invoke-virtual {v1, p1}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;
  531. invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
  532. move-result-object p1
  533. invoke-direct {v0, p1}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V
  534. throw v0
  535. :try_end_1
  536. .catchall {:try_start_1 .. :try_end_1} :catchall_0
  537. :goto_0
  538. monitor-exit p0
  539. throw p1
  540. .end method
  541. .method public declared-synchronized setMaxRequestsPerHost(I)V
  542. .locals 3
  543. monitor-enter p0
  544. const/4 v0, 0x1
  545. if-lt p1, v0, :cond_0
  546. :try_start_0
  547. iput p1, p0, Lokhttp3/Dispatcher;->maxRequestsPerHost:I
  548. invoke-direct {p0}, Lokhttp3/Dispatcher;->promoteCalls()V
  549. :try_end_0
  550. .catchall {:try_start_0 .. :try_end_0} :catchall_0
  551. monitor-exit p0
  552. return-void
  553. :catchall_0
  554. move-exception p1
  555. goto :goto_0
  556. :cond_0
  557. :try_start_1
  558. new-instance v0, Ljava/lang/IllegalArgumentException;
  559. new-instance v1, Ljava/lang/StringBuilder;
  560. invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V
  561. const-string v2, "max < 1: "
  562. invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  563. invoke-virtual {v1, p1}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;
  564. invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
  565. move-result-object p1
  566. invoke-direct {v0, p1}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V
  567. throw v0
  568. :try_end_1
  569. .catchall {:try_start_1 .. :try_end_1} :catchall_0
  570. :goto_0
  571. monitor-exit p0
  572. throw p1
  573. .end method