SegmentPool.smali

.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\t\n\u0002\u0008\u0006\n\u0002\u0018\u0002\n\u0002\u0008\u0005\n\u0002\u0010\u0002\n\u0002\u0008\u0003\u0008\u00c1\u0002\u0018\u00002\u00020\u0001B\u0007\u0008\u0002\u00a2\u0006\u0002\u0010\u0002J\u000e\u0010\u0010\u001a\u00020\u00112\u0006\u0010\u0012\u001a\u00020\u000bJ\u0006\u0010\u0013\u001a\u00020\u000bR\u000e\u0010\u0003\u001a\u00020\u0004X\u0086T\u00a2\u0006\u0002\n\u0000R\u001a\u0010\u0005\u001a\u00020\u0004X\u0086\u000e\u00a2\u0006\u000e\n\u0000\u001a\u0004\u0008\u0006\u0010\u0007\"\u0004\u0008\u0008\u0010\tR\u001c\u0010\n\u001a\u0004\u0018\u00010\u000bX\u0086\u000e\u00a2\u0006\u000e\n\u0000\u001a\u0004\u0008\u000c\u0010\r\"\u0004\u0008\u000e\u0010\u000f\u00a8\u0006\u0014"
    }
    d2 = {
        "Lokio/SegmentPool;",
        "",
        "()V",
        "MAX_SIZE",
        "",
        "byteCount",
        "getByteCount",
        "()J",
        "setByteCount",
        "(J)V",
        "next",
        "Lokio/Segment;",
        "getNext",
        "()Lokio/Segment;",
        "setNext",
        "(Lokio/Segment;)V",
        "recycle",
        "",
        "segment",
        "take",
        "okio"
    }
    k = 0x1
    mv = {
        0x1,
        0x1,
        0x10
    }
.end annotation


# static fields
.field public static final INSTANCE:Lokio/SegmentPool;

.field public static final MAX_SIZE:J = 0x10000L

.field public static byteCount:J

.field public static next:Lokio/Segment;


# direct methods
.method public static constructor <clinit>()V
    .registers 1

    new-instance v0, Lokio/SegmentPool;

    invoke-direct {v0}, Lokio/SegmentPool;-><init>()V

    sput-object v0, Lokio/SegmentPool;->INSTANCE:Lokio/SegmentPool;

    return-void
.end method

.method public constructor <init>()V
    .registers 1

    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    return-void
.end method


# virtual methods
.method public final getByteCount()J
    .registers 3

    sget-wide v0, Lokio/SegmentPool;->byteCount:J

    return-wide v0
.end method

.method public final getNext()Lokio/Segment;
    .registers 2

    sget-object v0, Lokio/SegmentPool;->next:Lokio/Segment;

    return-object v0
.end method

.method public final recycle(Lokio/Segment;)V
    .registers 10

    iget-object v0, p1, Lokio/Segment;->next:Lokio/Segment;

    const/4 v1, 0x0

    if-nez v0, :cond_b

    iget-object v0, p1, Lokio/Segment;->prev:Lokio/Segment;

    if-nez v0, :cond_b

    const/4 v0, 0x1

    goto :goto_c

    :cond_b
    const/4 v0, 0x0

    :goto_c
    if-eqz v0, :cond_39

    iget-boolean v0, p1, Lokio/Segment;->shared:Z

    if-eqz v0, :cond_13

    return-void

    :cond_13
    monitor-enter p0

    :try_start_14
    sget-wide v2, Lokio/SegmentPool;->byteCount:J
    :try_end_16
    .catchall {:try_start_14 .. :try_end_16} :catchall_36

    const/16 v0, 0x2000

    int-to-long v4, v0

    add-long/2addr v2, v4

    const-wide/32 v6, 0x10000

    cmp-long v0, v2, v6

    if-lez v0, :cond_23

    monitor-exit p0

    return-void

    :cond_23
    :try_start_23
    sget-wide v2, Lokio/SegmentPool;->byteCount:J

    add-long/2addr v2, v4

    sput-wide v2, Lokio/SegmentPool;->byteCount:J

    sget-object v0, Lokio/SegmentPool;->next:Lokio/Segment;

    iput-object v0, p1, Lokio/Segment;->next:Lokio/Segment;

    iput v1, p1, Lokio/Segment;->limit:I

    iput v1, p1, Lokio/Segment;->pos:I

    sput-object p1, Lokio/SegmentPool;->next:Lokio/Segment;

    sget-object p1, Lkotlin/Unit;->INSTANCE:Lkotlin/Unit;
    :try_end_34
    .catchall {:try_start_23 .. :try_end_34} :catchall_36

    monitor-exit p0

    return-void

    :catchall_36
    move-exception p1

    monitor-exit p0

    throw p1

    :cond_39
    new-instance p1, Ljava/lang/IllegalArgumentException;

    const-string v0, "Failed requirement."

    invoke-virtual {v0}, Ljava/lang/Object;->toString()Ljava/lang/String;

    move-result-object v0

    invoke-direct {p1, v0}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V

    throw p1
.end method

.method public final setByteCount(J)V
    .registers 3

    sput-wide p1, Lokio/SegmentPool;->byteCount:J

    return-void
.end method

.method public final setNext(Lokio/Segment;)V
    .registers 2

    sput-object p1, Lokio/SegmentPool;->next:Lokio/Segment;

    return-void
.end method

.method public final take()Lokio/Segment;
    .registers 6

    monitor-enter p0

    :try_start_1
    sget-object v0, Lokio/SegmentPool;->next:Lokio/Segment;

    if-eqz v0, :cond_16

    iget-object v1, v0, Lokio/Segment;->next:Lokio/Segment;

    sput-object v1, Lokio/SegmentPool;->next:Lokio/Segment;

    const/4 v1, 0x0

    iput-object v1, v0, Lokio/Segment;->next:Lokio/Segment;

    sget-wide v1, Lokio/SegmentPool;->byteCount:J

    const/16 v3, 0x2000

    int-to-long v3, v3

    sub-long/2addr v1, v3

    sput-wide v1, Lokio/SegmentPool;->byteCount:J
    :try_end_14
    .catchall {:try_start_1 .. :try_end_14} :catchall_1d

    monitor-exit p0

    return-object v0

    :cond_16
    monitor-exit p0

    new-instance v0, Lokio/Segment;

    invoke-direct {v0}, Lokio/Segment;-><init>()V

    return-object v0

    :catchall_1d
    move-exception v0

    monitor-exit p0

    throw v0
.end method