.class public final Lokio/SegmentPool; .super Ljava/lang/Object; .source "SegmentPool.kt" # annotations .annotation runtime Lkotlin/Metadata; bv = { 0x1, 0x0, 0x3 } d1 = { "\u0000.\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\u0008\u0002\n\u0002\u0010\u0008\n\u0000\n\u0002\u0018\u0002\n\u0002\u0008\u0006\n\u0002\u0010\u0011\n\u0002\u0018\u0002\n\u0002\u0008\u0003\n\u0002\u0010\u0002\n\u0002\u0008\u0003\u0008\u00c0\u0002\u0018\u00002\u00020\u0001B\u0007\u0008\u0002\u00a2\u0006\u0002\u0010\u0002J\u0010\u0010\u0010\u001a\n\u0012\u0006\u0012\u0004\u0018\u00010\u00060\u000eH\u0002J\u0010\u0010\u0011\u001a\u00020\u00122\u0006\u0010\u0013\u001a\u00020\u0006H\u0007J\u0008\u0010\u0014\u001a\u00020\u0006H\u0007R\u000e\u0010\u0003\u001a\u00020\u0004X\u0082\u0004\u00a2\u0006\u0002\n\u0000R\u000e\u0010\u0005\u001a\u00020\u0006X\u0082\u0004\u00a2\u0006\u0002\n\u0000R\u0014\u0010\u0007\u001a\u00020\u0004X\u0086D\u00a2\u0006\u0008\n\u0000\u001a\u0004\u0008\u0008\u0010\tR\u0011\u0010\n\u001a\u00020\u00048F\u00a2\u0006\u0006\u001a\u0004\u0008\u000b\u0010\tR\u001e\u0010\u000c\u001a\u0010\u0012\u000c\u0012\n\u0012\u0006\u0012\u0004\u0018\u00010\u00060\u000e0\rX\u0082\u0004\u00a2\u0006\u0004\n\u0002\u0010\u000f\u00a8\u0006\u0015" } d2 = { "Lokio/SegmentPool;", "", "()V", "HASH_BUCKET_COUNT", "", "LOCK", "Lokio/Segment;", "MAX_SIZE", "getMAX_SIZE", "()I", "byteCount", "getByteCount", "hashBuckets", "", "Ljava/util/concurrent/atomic/AtomicReference;", "[Ljava/util/concurrent/atomic/AtomicReference;", "firstRef", "recycle", "", "segment", "take", "okio" } k = 0x1 mv = { 0x1, 0x4, 0x0 } .end annotation # static fields .field private static final HASH_BUCKET_COUNT:I .field public static final INSTANCE:Lokio/SegmentPool; .field private static final LOCK:Lokio/Segment; .field private static final MAX_SIZE:I .field private static final hashBuckets:[Ljava/util/concurrent/atomic/AtomicReference; .annotation system Ldalvik/annotation/Signature; value = { "[", "Ljava/util/concurrent/atomic/AtomicReference<", "Lokio/Segment;", ">;" } .end annotation .end field # direct methods .method static constructor ()V .locals 8 .line 40 new-instance v0, Lokio/SegmentPool; invoke-direct {v0}, Lokio/SegmentPool;->()V sput-object v0, Lokio/SegmentPool;->INSTANCE:Lokio/SegmentPool; const/high16 v0, 0x10000 sput v0, Lokio/SegmentPool;->MAX_SIZE:I .line 46 new-instance v0, Lokio/Segment; const/4 v7, 0x0 new-array v2, v7, [B const/4 v3, 0x0 const/4 v4, 0x0 const/4 v5, 0x0 const/4 v6, 0x0 move-object v1, v0 invoke-direct/range {v1 .. v6}, Lokio/Segment;->([BIIZZ)V sput-object v0, Lokio/SegmentPool;->LOCK:Lokio/Segment; .line 54 invoke-static {}, Ljava/lang/Runtime;->getRuntime()Ljava/lang/Runtime; move-result-object v0 invoke-virtual {v0}, Ljava/lang/Runtime;->availableProcessors()I move-result v0 mul-int/lit8 v0, v0, 0x2 add-int/lit8 v0, v0, -0x1 invoke-static {v0}, Ljava/lang/Integer;->highestOneBit(I)I move-result v0 sput v0, Lokio/SegmentPool;->HASH_BUCKET_COUNT:I .line 64 new-array v1, v0, [Ljava/util/concurrent/atomic/AtomicReference; :goto_0 if-ge v7, v0, :cond_0 .line 65 new-instance v2, Ljava/util/concurrent/atomic/AtomicReference; invoke-direct {v2}, Ljava/util/concurrent/atomic/AtomicReference;->()V aput-object v2, v1, v7 add-int/lit8 v7, v7, 0x1 goto :goto_0 :cond_0 sput-object v1, Lokio/SegmentPool;->hashBuckets:[Ljava/util/concurrent/atomic/AtomicReference; return-void .end method .method private constructor ()V .locals 0 .line 40 invoke-direct {p0}, Ljava/lang/Object;->()V return-void .end method .method private final firstRef()Ljava/util/concurrent/atomic/AtomicReference; .locals 6 .annotation system Ldalvik/annotation/Signature; value = { "()", "Ljava/util/concurrent/atomic/AtomicReference<", "Lokio/Segment;", ">;" } .end annotation .line 121 invoke-static {}, Ljava/lang/Thread;->currentThread()Ljava/lang/Thread; move-result-object p0 const-string v0, "Thread.currentThread()" invoke-static {p0, v0}, Lkotlin/jvm/internal/Intrinsics;->checkNotNullExpressionValue(Ljava/lang/Object;Ljava/lang/String;)V invoke-virtual {p0}, Ljava/lang/Thread;->getId()J move-result-wide v0 sget p0, Lokio/SegmentPool;->HASH_BUCKET_COUNT:I int-to-long v2, p0 const-wide/16 v4, 0x1 sub-long/2addr v2, v4 and-long/2addr v0, v2 long-to-int p0, v0 sget-object v0, Lokio/SegmentPool;->hashBuckets:[Ljava/util/concurrent/atomic/AtomicReference; .line 122 aget-object p0, v0, p0 return-object p0 .end method .method public static final recycle(Lokio/Segment;)V .locals 5 .annotation runtime Lkotlin/jvm/JvmStatic; .end annotation const-string v0, "segment" invoke-static {p0, v0}, Lkotlin/jvm/internal/Intrinsics;->checkNotNullParameter(Ljava/lang/Object;Ljava/lang/String;)V .line 101 iget-object v0, p0, Lokio/Segment;->next:Lokio/Segment; const/4 v1, 0x0 if-nez v0, :cond_0 iget-object v0, p0, Lokio/Segment;->prev:Lokio/Segment; if-nez v0, :cond_0 const/4 v0, 0x1 goto :goto_0 :cond_0 move v0, v1 :goto_0 if-eqz v0, :cond_6 .line 102 iget-boolean v0, p0, Lokio/Segment;->shared:Z if-eqz v0, :cond_1 return-void :cond_1 sget-object v0, Lokio/SegmentPool;->INSTANCE:Lokio/SegmentPool; .line 104 invoke-direct {v0}, Lokio/SegmentPool;->firstRef()Ljava/util/concurrent/atomic/AtomicReference; move-result-object v0 .line 106 invoke-virtual {v0}, Ljava/util/concurrent/atomic/AtomicReference;->get()Ljava/lang/Object; move-result-object v2 check-cast v2, Lokio/Segment; sget-object v3, Lokio/SegmentPool;->LOCK:Lokio/Segment; if-ne v2, v3, :cond_2 return-void :cond_2 if-eqz v2, :cond_3 .line 108 iget v3, v2, Lokio/Segment;->limit:I goto :goto_1 :cond_3 move v3, v1 :goto_1 sget v4, Lokio/SegmentPool;->MAX_SIZE:I if-lt v3, v4, :cond_4 return-void .line 111 :cond_4 iput-object v2, p0, Lokio/Segment;->next:Lokio/Segment; .line 112 iput v1, p0, Lokio/Segment;->pos:I add-int/lit16 v3, v3, 0x2000 .line 113 iput v3, p0, Lokio/Segment;->limit:I .line 115 invoke-virtual {v0, v2, p0}, Ljava/util/concurrent/atomic/AtomicReference;->compareAndSet(Ljava/lang/Object;Ljava/lang/Object;)Z move-result v0 if-nez v0, :cond_5 const/4 v0, 0x0 move-object v1, v0 check-cast v1, Lokio/Segment; iput-object v0, p0, Lokio/Segment;->next:Lokio/Segment; :cond_5 return-void .line 101 :cond_6 new-instance p0, Ljava/lang/IllegalArgumentException; const-string v0, "Failed requirement." invoke-virtual {v0}, Ljava/lang/Object;->toString()Ljava/lang/String; move-result-object v0 invoke-direct {p0, v0}, Ljava/lang/IllegalArgumentException;->(Ljava/lang/String;)V check-cast p0, Ljava/lang/Throwable; throw p0 .end method .method public static final take()Lokio/Segment; .locals 4 .annotation runtime Lkotlin/jvm/JvmStatic; .end annotation sget-object v0, Lokio/SegmentPool;->INSTANCE:Lokio/SegmentPool; .line 76 invoke-direct {v0}, Lokio/SegmentPool;->firstRef()Ljava/util/concurrent/atomic/AtomicReference; move-result-object v0 sget-object v1, Lokio/SegmentPool;->LOCK:Lokio/Segment; .line 78 invoke-virtual {v0, v1}, Ljava/util/concurrent/atomic/AtomicReference;->getAndSet(Ljava/lang/Object;)Ljava/lang/Object; move-result-object v2 check-cast v2, Lokio/Segment; if-ne v2, v1, :cond_0 .line 82 new-instance v0, Lokio/Segment; invoke-direct {v0}, Lokio/Segment;->()V return-object v0 :cond_0 const/4 v1, 0x0 if-nez v2, :cond_1 .line 86 invoke-virtual {v0, v1}, Ljava/util/concurrent/atomic/AtomicReference;->set(Ljava/lang/Object;)V .line 87 new-instance v0, Lokio/Segment; invoke-direct {v0}, Lokio/Segment;->()V return-object v0 .line 91 :cond_1 iget-object v3, v2, Lokio/Segment;->next:Lokio/Segment; invoke-virtual {v0, v3}, Ljava/util/concurrent/atomic/AtomicReference;->set(Ljava/lang/Object;)V .line 92 move-object v0, v1 check-cast v0, Lokio/Segment; iput-object v1, v2, Lokio/Segment;->next:Lokio/Segment; const/4 v0, 0x0 .line 93 iput v0, v2, Lokio/Segment;->limit:I return-object v2 .end method # virtual methods .method public final getByteCount()I .locals 0 .line 70 invoke-direct {p0}, Lokio/SegmentPool;->firstRef()Ljava/util/concurrent/atomic/AtomicReference; move-result-object p0 invoke-virtual {p0}, Ljava/util/concurrent/atomic/AtomicReference;->get()Ljava/lang/Object; move-result-object p0 check-cast p0, Lokio/Segment; if-eqz p0, :cond_0 .line 71 iget p0, p0, Lokio/Segment;->limit:I return p0 :cond_0 const/4 p0, 0x0 return p0 .end method .method public final getMAX_SIZE()I .locals 0 sget p0, Lokio/SegmentPool;->MAX_SIZE:I return p0 .end method