Pipe$PipeSink.smali 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  1. .class final Lokio/Pipe$PipeSink;
  2. .super Ljava/lang/Object;
  3. .source ""
  4. # interfaces
  5. .implements Lokio/Sink;
  6. # annotations
  7. .annotation system Ldalvik/annotation/EnclosingClass;
  8. value = Lokio/Pipe;
  9. .end annotation
  10. .annotation system Ldalvik/annotation/InnerClass;
  11. accessFlags = 0x10
  12. name = "PipeSink"
  13. .end annotation
  14. # instance fields
  15. .field final synthetic this$0:Lokio/Pipe;
  16. .field final timeout:Lokio/Timeout;
  17. # direct methods
  18. .method constructor <init>(Lokio/Pipe;)V
  19. .locals 0
  20. iput-object p1, p0, Lokio/Pipe$PipeSink;->this$0:Lokio/Pipe;
  21. invoke-direct {p0}, Ljava/lang/Object;-><init>()V
  22. new-instance p1, Lokio/Timeout;
  23. invoke-direct {p1}, Lokio/Timeout;-><init>()V
  24. iput-object p1, p0, Lokio/Pipe$PipeSink;->timeout:Lokio/Timeout;
  25. return-void
  26. .end method
  27. # virtual methods
  28. .method public close()V
  29. .locals 6
  30. .annotation system Ldalvik/annotation/Throws;
  31. value = {
  32. Ljava/io/IOException;
  33. }
  34. .end annotation
  35. iget-object v0, p0, Lokio/Pipe$PipeSink;->this$0:Lokio/Pipe;
  36. iget-object v0, v0, Lokio/Pipe;->buffer:Lokio/Buffer;
  37. monitor-enter v0
  38. :try_start_0
  39. iget-object v1, p0, Lokio/Pipe$PipeSink;->this$0:Lokio/Pipe;
  40. iget-boolean v1, v1, Lokio/Pipe;->sinkClosed:Z
  41. if-eqz v1, :cond_0
  42. monitor-exit v0
  43. return-void
  44. :cond_0
  45. iget-object v1, p0, Lokio/Pipe$PipeSink;->this$0:Lokio/Pipe;
  46. iget-boolean v1, v1, Lokio/Pipe;->sourceClosed:Z
  47. if-eqz v1, :cond_2
  48. iget-object v1, p0, Lokio/Pipe$PipeSink;->this$0:Lokio/Pipe;
  49. iget-object v1, v1, Lokio/Pipe;->buffer:Lokio/Buffer;
  50. invoke-virtual {v1}, Lokio/Buffer;->size()J
  51. move-result-wide v1
  52. const-wide/16 v3, 0x0
  53. cmp-long v5, v1, v3
  54. if-gtz v5, :cond_1
  55. goto :goto_0
  56. :cond_1
  57. new-instance v1, Ljava/io/IOException;
  58. const-string v2, "source is closed"
  59. invoke-direct {v1, v2}, Ljava/io/IOException;-><init>(Ljava/lang/String;)V
  60. throw v1
  61. :cond_2
  62. :goto_0
  63. iget-object v1, p0, Lokio/Pipe$PipeSink;->this$0:Lokio/Pipe;
  64. const/4 v2, 0x1
  65. iput-boolean v2, v1, Lokio/Pipe;->sinkClosed:Z
  66. iget-object v1, p0, Lokio/Pipe$PipeSink;->this$0:Lokio/Pipe;
  67. iget-object v1, v1, Lokio/Pipe;->buffer:Lokio/Buffer;
  68. invoke-virtual {v1}, Ljava/lang/Object;->notifyAll()V
  69. monitor-exit v0
  70. return-void
  71. :catchall_0
  72. move-exception v1
  73. monitor-exit v0
  74. :try_end_0
  75. .catchall {:try_start_0 .. :try_end_0} :catchall_0
  76. throw v1
  77. .end method
  78. .method public flush()V
  79. .locals 6
  80. .annotation system Ldalvik/annotation/Throws;
  81. value = {
  82. Ljava/io/IOException;
  83. }
  84. .end annotation
  85. iget-object v0, p0, Lokio/Pipe$PipeSink;->this$0:Lokio/Pipe;
  86. iget-object v0, v0, Lokio/Pipe;->buffer:Lokio/Buffer;
  87. monitor-enter v0
  88. :try_start_0
  89. iget-object v1, p0, Lokio/Pipe$PipeSink;->this$0:Lokio/Pipe;
  90. iget-boolean v1, v1, Lokio/Pipe;->sinkClosed:Z
  91. if-nez v1, :cond_2
  92. iget-object v1, p0, Lokio/Pipe$PipeSink;->this$0:Lokio/Pipe;
  93. iget-boolean v1, v1, Lokio/Pipe;->sourceClosed:Z
  94. if-eqz v1, :cond_1
  95. iget-object v1, p0, Lokio/Pipe$PipeSink;->this$0:Lokio/Pipe;
  96. iget-object v1, v1, Lokio/Pipe;->buffer:Lokio/Buffer;
  97. invoke-virtual {v1}, Lokio/Buffer;->size()J
  98. move-result-wide v1
  99. const-wide/16 v3, 0x0
  100. cmp-long v5, v1, v3
  101. if-gtz v5, :cond_0
  102. goto :goto_0
  103. :cond_0
  104. new-instance v1, Ljava/io/IOException;
  105. const-string v2, "source is closed"
  106. invoke-direct {v1, v2}, Ljava/io/IOException;-><init>(Ljava/lang/String;)V
  107. throw v1
  108. :cond_1
  109. :goto_0
  110. monitor-exit v0
  111. return-void
  112. :cond_2
  113. new-instance v1, Ljava/lang/IllegalStateException;
  114. const-string v2, "closed"
  115. invoke-direct {v1, v2}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V
  116. throw v1
  117. :catchall_0
  118. move-exception v1
  119. monitor-exit v0
  120. :try_end_0
  121. .catchall {:try_start_0 .. :try_end_0} :catchall_0
  122. throw v1
  123. .end method
  124. .method public timeout()Lokio/Timeout;
  125. .locals 1
  126. iget-object v0, p0, Lokio/Pipe$PipeSink;->timeout:Lokio/Timeout;
  127. return-object v0
  128. .end method
  129. .method public write(Lokio/Buffer;J)V
  130. .locals 7
  131. .annotation system Ldalvik/annotation/Throws;
  132. value = {
  133. Ljava/io/IOException;
  134. }
  135. .end annotation
  136. iget-object v0, p0, Lokio/Pipe$PipeSink;->this$0:Lokio/Pipe;
  137. iget-object v0, v0, Lokio/Pipe;->buffer:Lokio/Buffer;
  138. monitor-enter v0
  139. :try_start_0
  140. iget-object v1, p0, Lokio/Pipe$PipeSink;->this$0:Lokio/Pipe;
  141. iget-boolean v1, v1, Lokio/Pipe;->sinkClosed:Z
  142. if-nez v1, :cond_3
  143. :goto_0
  144. const-wide/16 v1, 0x0
  145. cmp-long v3, p2, v1
  146. if-lez v3, :cond_2
  147. iget-object v3, p0, Lokio/Pipe$PipeSink;->this$0:Lokio/Pipe;
  148. iget-boolean v3, v3, Lokio/Pipe;->sourceClosed:Z
  149. if-nez v3, :cond_1
  150. iget-object v3, p0, Lokio/Pipe$PipeSink;->this$0:Lokio/Pipe;
  151. iget-wide v3, v3, Lokio/Pipe;->maxBufferSize:J
  152. iget-object v5, p0, Lokio/Pipe$PipeSink;->this$0:Lokio/Pipe;
  153. iget-object v5, v5, Lokio/Pipe;->buffer:Lokio/Buffer;
  154. invoke-virtual {v5}, Lokio/Buffer;->size()J
  155. move-result-wide v5
  156. sub-long/2addr v3, v5
  157. cmp-long v5, v3, v1
  158. if-nez v5, :cond_0
  159. iget-object v1, p0, Lokio/Pipe$PipeSink;->timeout:Lokio/Timeout;
  160. iget-object v2, p0, Lokio/Pipe$PipeSink;->this$0:Lokio/Pipe;
  161. iget-object v2, v2, Lokio/Pipe;->buffer:Lokio/Buffer;
  162. invoke-virtual {v1, v2}, Lokio/Timeout;->waitUntilNotified(Ljava/lang/Object;)V
  163. goto :goto_0
  164. :cond_0
  165. invoke-static {v3, v4, p2, p3}, Ljava/lang/Math;->min(JJ)J
  166. move-result-wide v1
  167. iget-object v3, p0, Lokio/Pipe$PipeSink;->this$0:Lokio/Pipe;
  168. iget-object v3, v3, Lokio/Pipe;->buffer:Lokio/Buffer;
  169. invoke-virtual {v3, p1, v1, v2}, Lokio/Buffer;->write(Lokio/Buffer;J)V
  170. sub-long/2addr p2, v1
  171. iget-object v1, p0, Lokio/Pipe$PipeSink;->this$0:Lokio/Pipe;
  172. iget-object v1, v1, Lokio/Pipe;->buffer:Lokio/Buffer;
  173. invoke-virtual {v1}, Ljava/lang/Object;->notifyAll()V
  174. goto :goto_0
  175. :cond_1
  176. new-instance p1, Ljava/io/IOException;
  177. const-string p2, "source is closed"
  178. invoke-direct {p1, p2}, Ljava/io/IOException;-><init>(Ljava/lang/String;)V
  179. throw p1
  180. :cond_2
  181. monitor-exit v0
  182. return-void
  183. :cond_3
  184. new-instance p1, Ljava/lang/IllegalStateException;
  185. const-string p2, "closed"
  186. invoke-direct {p1, p2}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V
  187. throw p1
  188. :catchall_0
  189. move-exception p1
  190. monitor-exit v0
  191. :try_end_0
  192. .catchall {:try_start_0 .. :try_end_0} :catchall_0
  193. goto :goto_2
  194. :goto_1
  195. throw p1
  196. :goto_2
  197. goto :goto_1
  198. .end method