MpscLinkedQueue.smali 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  1. .class public final Lio/reactivex/internal/queue/MpscLinkedQueue;
  2. .super Ljava/lang/Object;
  3. .source "MpscLinkedQueue.java"
  4. # interfaces
  5. .implements Lio/reactivex/internal/fuseable/SimplePlainQueue;
  6. # annotations
  7. .annotation system Ldalvik/annotation/MemberClasses;
  8. value = {
  9. Lio/reactivex/internal/queue/MpscLinkedQueue$LinkedQueueNode;
  10. }
  11. .end annotation
  12. .annotation system Ldalvik/annotation/Signature;
  13. value = {
  14. "<T:",
  15. "Ljava/lang/Object;",
  16. ">",
  17. "Ljava/lang/Object;",
  18. "Lio/reactivex/internal/fuseable/SimplePlainQueue<",
  19. "TT;>;"
  20. }
  21. .end annotation
  22. # instance fields
  23. .field private final consumerNode:Ljava/util/concurrent/atomic/AtomicReference;
  24. .annotation system Ldalvik/annotation/Signature;
  25. value = {
  26. "Ljava/util/concurrent/atomic/AtomicReference<",
  27. "Lio/reactivex/internal/queue/MpscLinkedQueue$LinkedQueueNode<",
  28. "TT;>;>;"
  29. }
  30. .end annotation
  31. .end field
  32. .field private final producerNode:Ljava/util/concurrent/atomic/AtomicReference;
  33. .annotation system Ldalvik/annotation/Signature;
  34. value = {
  35. "Ljava/util/concurrent/atomic/AtomicReference<",
  36. "Lio/reactivex/internal/queue/MpscLinkedQueue$LinkedQueueNode<",
  37. "TT;>;>;"
  38. }
  39. .end annotation
  40. .end field
  41. # direct methods
  42. .method public constructor <init>()V
  43. .locals 1
  44. .line 33
  45. invoke-direct {p0}, Ljava/lang/Object;-><init>()V
  46. .line 34
  47. new-instance v0, Ljava/util/concurrent/atomic/AtomicReference;
  48. invoke-direct {v0}, Ljava/util/concurrent/atomic/AtomicReference;-><init>()V
  49. iput-object v0, p0, Lio/reactivex/internal/queue/MpscLinkedQueue;->producerNode:Ljava/util/concurrent/atomic/AtomicReference;
  50. .line 35
  51. new-instance v0, Ljava/util/concurrent/atomic/AtomicReference;
  52. invoke-direct {v0}, Ljava/util/concurrent/atomic/AtomicReference;-><init>()V
  53. iput-object v0, p0, Lio/reactivex/internal/queue/MpscLinkedQueue;->consumerNode:Ljava/util/concurrent/atomic/AtomicReference;
  54. .line 36
  55. new-instance v0, Lio/reactivex/internal/queue/MpscLinkedQueue$LinkedQueueNode;
  56. invoke-direct {v0}, Lio/reactivex/internal/queue/MpscLinkedQueue$LinkedQueueNode;-><init>()V
  57. .line 37
  58. invoke-virtual {p0, v0}, Lio/reactivex/internal/queue/MpscLinkedQueue;->spConsumerNode(Lio/reactivex/internal/queue/MpscLinkedQueue$LinkedQueueNode;)V
  59. .line 38
  60. invoke-virtual {p0, v0}, Lio/reactivex/internal/queue/MpscLinkedQueue;->xchgProducerNode(Lio/reactivex/internal/queue/MpscLinkedQueue$LinkedQueueNode;)Lio/reactivex/internal/queue/MpscLinkedQueue$LinkedQueueNode;
  61. return-void
  62. .end method
  63. # virtual methods
  64. .method public clear()V
  65. .locals 1
  66. .line 116
  67. :goto_0
  68. invoke-virtual {p0}, Lio/reactivex/internal/queue/MpscLinkedQueue;->poll()Ljava/lang/Object;
  69. move-result-object v0
  70. if-eqz v0, :cond_0
  71. invoke-virtual {p0}, Lio/reactivex/internal/queue/MpscLinkedQueue;->isEmpty()Z
  72. move-result v0
  73. if-nez v0, :cond_0
  74. goto :goto_0
  75. :cond_0
  76. return-void
  77. .end method
  78. .method public isEmpty()Z
  79. .locals 2
  80. .line 145
  81. invoke-virtual {p0}, Lio/reactivex/internal/queue/MpscLinkedQueue;->lvConsumerNode()Lio/reactivex/internal/queue/MpscLinkedQueue$LinkedQueueNode;
  82. move-result-object v0
  83. invoke-virtual {p0}, Lio/reactivex/internal/queue/MpscLinkedQueue;->lvProducerNode()Lio/reactivex/internal/queue/MpscLinkedQueue$LinkedQueueNode;
  84. move-result-object v1
  85. if-ne v0, v1, :cond_0
  86. const/4 v0, 0x1
  87. goto :goto_0
  88. :cond_0
  89. const/4 v0, 0x0
  90. :goto_0
  91. return v0
  92. .end method
  93. .method lpConsumerNode()Lio/reactivex/internal/queue/MpscLinkedQueue$LinkedQueueNode;
  94. .locals 1
  95. .annotation system Ldalvik/annotation/Signature;
  96. value = {
  97. "()",
  98. "Lio/reactivex/internal/queue/MpscLinkedQueue$LinkedQueueNode<",
  99. "TT;>;"
  100. }
  101. .end annotation
  102. .line 129
  103. iget-object v0, p0, Lio/reactivex/internal/queue/MpscLinkedQueue;->consumerNode:Ljava/util/concurrent/atomic/AtomicReference;
  104. invoke-virtual {v0}, Ljava/util/concurrent/atomic/AtomicReference;->get()Ljava/lang/Object;
  105. move-result-object v0
  106. check-cast v0, Lio/reactivex/internal/queue/MpscLinkedQueue$LinkedQueueNode;
  107. return-object v0
  108. .end method
  109. .method lvConsumerNode()Lio/reactivex/internal/queue/MpscLinkedQueue$LinkedQueueNode;
  110. .locals 1
  111. .annotation system Ldalvik/annotation/Signature;
  112. value = {
  113. "()",
  114. "Lio/reactivex/internal/queue/MpscLinkedQueue$LinkedQueueNode<",
  115. "TT;>;"
  116. }
  117. .end annotation
  118. .line 125
  119. iget-object v0, p0, Lio/reactivex/internal/queue/MpscLinkedQueue;->consumerNode:Ljava/util/concurrent/atomic/AtomicReference;
  120. invoke-virtual {v0}, Ljava/util/concurrent/atomic/AtomicReference;->get()Ljava/lang/Object;
  121. move-result-object v0
  122. check-cast v0, Lio/reactivex/internal/queue/MpscLinkedQueue$LinkedQueueNode;
  123. return-object v0
  124. .end method
  125. .method lvProducerNode()Lio/reactivex/internal/queue/MpscLinkedQueue$LinkedQueueNode;
  126. .locals 1
  127. .annotation system Ldalvik/annotation/Signature;
  128. value = {
  129. "()",
  130. "Lio/reactivex/internal/queue/MpscLinkedQueue$LinkedQueueNode<",
  131. "TT;>;"
  132. }
  133. .end annotation
  134. .line 119
  135. iget-object v0, p0, Lio/reactivex/internal/queue/MpscLinkedQueue;->producerNode:Ljava/util/concurrent/atomic/AtomicReference;
  136. invoke-virtual {v0}, Ljava/util/concurrent/atomic/AtomicReference;->get()Ljava/lang/Object;
  137. move-result-object v0
  138. check-cast v0, Lio/reactivex/internal/queue/MpscLinkedQueue$LinkedQueueNode;
  139. return-object v0
  140. .end method
  141. .method public offer(Ljava/lang/Object;)Z
  142. .locals 1
  143. .annotation system Ldalvik/annotation/Signature;
  144. value = {
  145. "(TT;)Z"
  146. }
  147. .end annotation
  148. if-eqz p1, :cond_0
  149. .line 61
  150. new-instance v0, Lio/reactivex/internal/queue/MpscLinkedQueue$LinkedQueueNode;
  151. invoke-direct {v0, p1}, Lio/reactivex/internal/queue/MpscLinkedQueue$LinkedQueueNode;-><init>(Ljava/lang/Object;)V
  152. .line 62
  153. invoke-virtual {p0, v0}, Lio/reactivex/internal/queue/MpscLinkedQueue;->xchgProducerNode(Lio/reactivex/internal/queue/MpscLinkedQueue$LinkedQueueNode;)Lio/reactivex/internal/queue/MpscLinkedQueue$LinkedQueueNode;
  154. move-result-object p1
  155. .line 65
  156. invoke-virtual {p1, v0}, Lio/reactivex/internal/queue/MpscLinkedQueue$LinkedQueueNode;->soNext(Lio/reactivex/internal/queue/MpscLinkedQueue$LinkedQueueNode;)V
  157. const/4 p1, 0x1
  158. return p1
  159. .line 59
  160. :cond_0
  161. new-instance p1, Ljava/lang/NullPointerException;
  162. const-string v0, "Null is not a valid element"
  163. invoke-direct {p1, v0}, Ljava/lang/NullPointerException;-><init>(Ljava/lang/String;)V
  164. throw p1
  165. .end method
  166. .method public offer(Ljava/lang/Object;Ljava/lang/Object;)Z
  167. .locals 0
  168. .annotation system Ldalvik/annotation/Signature;
  169. value = {
  170. "(TT;TT;)Z"
  171. }
  172. .end annotation
  173. .line 109
  174. invoke-virtual {p0, p1}, Lio/reactivex/internal/queue/MpscLinkedQueue;->offer(Ljava/lang/Object;)Z
  175. .line 110
  176. invoke-virtual {p0, p2}, Lio/reactivex/internal/queue/MpscLinkedQueue;->offer(Ljava/lang/Object;)Z
  177. const/4 p1, 0x1
  178. return p1
  179. .end method
  180. .method public poll()Ljava/lang/Object;
  181. .locals 2
  182. .annotation system Ldalvik/annotation/Signature;
  183. value = {
  184. "()TT;"
  185. }
  186. .end annotation
  187. .line 86
  188. invoke-virtual {p0}, Lio/reactivex/internal/queue/MpscLinkedQueue;->lpConsumerNode()Lio/reactivex/internal/queue/MpscLinkedQueue$LinkedQueueNode;
  189. move-result-object v0
  190. .line 87
  191. invoke-virtual {v0}, Lio/reactivex/internal/queue/MpscLinkedQueue$LinkedQueueNode;->lvNext()Lio/reactivex/internal/queue/MpscLinkedQueue$LinkedQueueNode;
  192. move-result-object v1
  193. if-eqz v1, :cond_0
  194. .line 90
  195. invoke-virtual {v1}, Lio/reactivex/internal/queue/MpscLinkedQueue$LinkedQueueNode;->getAndNullValue()Ljava/lang/Object;
  196. move-result-object v0
  197. .line 91
  198. invoke-virtual {p0, v1}, Lio/reactivex/internal/queue/MpscLinkedQueue;->spConsumerNode(Lio/reactivex/internal/queue/MpscLinkedQueue$LinkedQueueNode;)V
  199. return-object v0
  200. .line 94
  201. :cond_0
  202. invoke-virtual {p0}, Lio/reactivex/internal/queue/MpscLinkedQueue;->lvProducerNode()Lio/reactivex/internal/queue/MpscLinkedQueue$LinkedQueueNode;
  203. move-result-object v1
  204. if-eq v0, v1, :cond_2
  205. .line 96
  206. :goto_0
  207. invoke-virtual {v0}, Lio/reactivex/internal/queue/MpscLinkedQueue$LinkedQueueNode;->lvNext()Lio/reactivex/internal/queue/MpscLinkedQueue$LinkedQueueNode;
  208. move-result-object v1
  209. if-nez v1, :cond_1
  210. goto :goto_0
  211. .line 100
  212. :cond_1
  213. invoke-virtual {v1}, Lio/reactivex/internal/queue/MpscLinkedQueue$LinkedQueueNode;->getAndNullValue()Ljava/lang/Object;
  214. move-result-object v0
  215. .line 101
  216. invoke-virtual {p0, v1}, Lio/reactivex/internal/queue/MpscLinkedQueue;->spConsumerNode(Lio/reactivex/internal/queue/MpscLinkedQueue$LinkedQueueNode;)V
  217. return-object v0
  218. :cond_2
  219. const/4 v0, 0x0
  220. return-object v0
  221. .end method
  222. .method spConsumerNode(Lio/reactivex/internal/queue/MpscLinkedQueue$LinkedQueueNode;)V
  223. .locals 1
  224. .annotation system Ldalvik/annotation/Signature;
  225. value = {
  226. "(",
  227. "Lio/reactivex/internal/queue/MpscLinkedQueue$LinkedQueueNode<",
  228. "TT;>;)V"
  229. }
  230. .end annotation
  231. .line 132
  232. iget-object v0, p0, Lio/reactivex/internal/queue/MpscLinkedQueue;->consumerNode:Ljava/util/concurrent/atomic/AtomicReference;
  233. invoke-virtual {v0, p1}, Ljava/util/concurrent/atomic/AtomicReference;->lazySet(Ljava/lang/Object;)V
  234. return-void
  235. .end method
  236. .method xchgProducerNode(Lio/reactivex/internal/queue/MpscLinkedQueue$LinkedQueueNode;)Lio/reactivex/internal/queue/MpscLinkedQueue$LinkedQueueNode;
  237. .locals 1
  238. .annotation system Ldalvik/annotation/Signature;
  239. value = {
  240. "(",
  241. "Lio/reactivex/internal/queue/MpscLinkedQueue$LinkedQueueNode<",
  242. "TT;>;)",
  243. "Lio/reactivex/internal/queue/MpscLinkedQueue$LinkedQueueNode<",
  244. "TT;>;"
  245. }
  246. .end annotation
  247. .line 122
  248. iget-object v0, p0, Lio/reactivex/internal/queue/MpscLinkedQueue;->producerNode:Ljava/util/concurrent/atomic/AtomicReference;
  249. invoke-virtual {v0, p1}, Ljava/util/concurrent/atomic/AtomicReference;->getAndSet(Ljava/lang/Object;)Ljava/lang/Object;
  250. move-result-object p1
  251. check-cast p1, Lio/reactivex/internal/queue/MpscLinkedQueue$LinkedQueueNode;
  252. return-object p1
  253. .end method