RunningJobSet.smali

.class public Lcom/path/android/jobqueue/RunningJobSet;
.super Ljava/lang/Object;
.source "SourceFile"


# instance fields
.field private groupDelayTimeout:J

.field private final groupDelays:Ljava/util/Map;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/Map<",
            "Ljava/lang/String;",
            "Ljava/lang/Long;",
            ">;"
        }
    .end annotation
.end field

.field private final internalSet:Ljava/util/TreeSet;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/TreeSet<",
            "Ljava/lang/String;",
            ">;"
        }
    .end annotation
.end field

.field private publicClone:Ljava/util/ArrayList;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/ArrayList<",
            "Ljava/lang/String;",
            ">;"
        }
    .end annotation
.end field


# direct methods
.method public constructor <init>()V
    .registers 3

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

    .line 2
    new-instance v0, Ljava/util/TreeSet;

    invoke-direct {v0}, Ljava/util/TreeSet;-><init>()V

    iput-object v0, p0, Lcom/path/android/jobqueue/RunningJobSet;->internalSet:Ljava/util/TreeSet;

    .line 3
    new-instance v0, Ljava/util/HashMap;

    invoke-direct {v0}, Ljava/util/HashMap;-><init>()V

    iput-object v0, p0, Lcom/path/android/jobqueue/RunningJobSet;->groupDelays:Ljava/util/Map;

    const-wide v0, 0x7fffffffffffffffL

    .line 4
    iput-wide v0, p0, Lcom/path/android/jobqueue/RunningJobSet;->groupDelayTimeout:J

    return-void
.end method

.method private calculateNextDelayForGroups()J
    .registers 8

    .line 1
    iget-object v0, p0, Lcom/path/android/jobqueue/RunningJobSet;->groupDelays:Ljava/util/Map;

    invoke-interface {v0}, Ljava/util/Map;->values()Ljava/util/Collection;

    move-result-object v0

    invoke-interface {v0}, Ljava/util/Collection;->iterator()Ljava/util/Iterator;

    move-result-object v0

    const-wide v1, 0x7fffffffffffffffL

    :cond_f
    :goto_f
    invoke-interface {v0}, Ljava/util/Iterator;->hasNext()Z

    move-result v3

    if-eqz v3, :cond_28

    invoke-interface {v0}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v3

    check-cast v3, Ljava/lang/Long;

    .line 2
    invoke-virtual {v3}, Ljava/lang/Long;->longValue()J

    move-result-wide v4

    cmp-long v6, v4, v1

    if-gez v6, :cond_f

    .line 3
    invoke-virtual {v3}, Ljava/lang/Long;->longValue()J

    move-result-wide v1

    goto :goto_f

    :cond_28
    return-wide v1
.end method


# virtual methods
.method public declared-synchronized add(Ljava/lang/String;)V
    .registers 3

    monitor-enter p0

    .line 1
    :try_start_1
    iget-object v0, p0, Lcom/path/android/jobqueue/RunningJobSet;->internalSet:Ljava/util/TreeSet;

    invoke-virtual {v0, p1}, Ljava/util/TreeSet;->add(Ljava/lang/Object;)Z

    move-result p1

    if-eqz p1, :cond_c

    const/4 p1, 0x0

    .line 2
    iput-object p1, p0, Lcom/path/android/jobqueue/RunningJobSet;->publicClone:Ljava/util/ArrayList;
    :try_end_c
    .catchall {:try_start_1 .. :try_end_c} :catchall_e

    .line 3
    :cond_c
    monitor-exit p0

    return-void

    :catchall_e
    move-exception p1

    monitor-exit p0

    throw p1
.end method

.method public declared-synchronized addGroupUntil(Ljava/lang/String;J)V
    .registers 7

    monitor-enter p0

    .line 1
    :try_start_1
    iget-object v0, p0, Lcom/path/android/jobqueue/RunningJobSet;->groupDelays:Ljava/util/Map;

    invoke-interface {v0, p1}, Ljava/util/Map;->get(Ljava/lang/Object;)Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Ljava/lang/Long;

    if-eqz v0, :cond_15

    .line 2
    invoke-virtual {v0}, Ljava/lang/Long;->longValue()J

    move-result-wide v0
    :try_end_f
    .catchall {:try_start_1 .. :try_end_f} :catchall_29

    cmp-long v2, v0, p2

    if-lez v2, :cond_15

    .line 3
    monitor-exit p0

    return-void

    .line 4
    :cond_15
    :try_start_15
    iget-object v0, p0, Lcom/path/android/jobqueue/RunningJobSet;->groupDelays:Ljava/util/Map;

    invoke-static {p2, p3}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;

    move-result-object p2

    invoke-interface {v0, p1, p2}, Ljava/util/Map;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

    .line 5
    invoke-direct {p0}, Lcom/path/android/jobqueue/RunningJobSet;->calculateNextDelayForGroups()J

    move-result-wide p1

    iput-wide p1, p0, Lcom/path/android/jobqueue/RunningJobSet;->groupDelayTimeout:J

    const/4 p1, 0x0

    .line 6
    iput-object p1, p0, Lcom/path/android/jobqueue/RunningJobSet;->publicClone:Ljava/util/ArrayList;
    :try_end_27
    .catchall {:try_start_15 .. :try_end_27} :catchall_29

    .line 7
    monitor-exit p0

    return-void

    :catchall_29
    move-exception p1

    monitor-exit p0

    throw p1
.end method

.method public declared-synchronized clear()V
    .registers 2

    monitor-enter p0

    .line 1
    :try_start_1
    iget-object v0, p0, Lcom/path/android/jobqueue/RunningJobSet;->internalSet:Ljava/util/TreeSet;

    invoke-virtual {v0}, Ljava/util/TreeSet;->clear()V

    .line 2
    iget-object v0, p0, Lcom/path/android/jobqueue/RunningJobSet;->groupDelays:Ljava/util/Map;

    invoke-interface {v0}, Ljava/util/Map;->clear()V

    const/4 v0, 0x0

    .line 3
    iput-object v0, p0, Lcom/path/android/jobqueue/RunningJobSet;->publicClone:Ljava/util/ArrayList;
    :try_end_e
    .catchall {:try_start_1 .. :try_end_e} :catchall_10

    .line 4
    monitor-exit p0

    return-void

    :catchall_10
    move-exception v0

    monitor-exit p0

    throw v0
.end method

.method public getNextDelayForGroups()Ljava/lang/Long;
    .registers 6

    .line 1
    iget-wide v0, p0, Lcom/path/android/jobqueue/RunningJobSet;->groupDelayTimeout:J

    const-wide v2, 0x7fffffffffffffffL

    cmp-long v4, v0, v2

    if-nez v4, :cond_d

    const/4 v0, 0x0

    return-object v0

    .line 2
    :cond_d
    invoke-static {v0, v1}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;

    move-result-object v0

    return-object v0
.end method

.method public declared-synchronized getSafe()Ljava/util/Collection;
    .registers 9
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "()",
            "Ljava/util/Collection<",
            "Ljava/lang/String;",
            ">;"
        }
    .end annotation

    monitor-enter p0

    .line 1
    :try_start_1
    invoke-virtual {p0}, Lcom/path/android/jobqueue/RunningJobSet;->now()J

    move-result-wide v0

    .line 2
    iget-object v2, p0, Lcom/path/android/jobqueue/RunningJobSet;->publicClone:Ljava/util/ArrayList;

    if-eqz v2, :cond_f

    iget-wide v2, p0, Lcom/path/android/jobqueue/RunningJobSet;->groupDelayTimeout:J

    cmp-long v4, v0, v2

    if-lez v4, :cond_76

    .line 3
    :cond_f
    iget-object v2, p0, Lcom/path/android/jobqueue/RunningJobSet;->groupDelays:Ljava/util/Map;

    invoke-interface {v2}, Ljava/util/Map;->isEmpty()Z

    move-result v2

    if-eqz v2, :cond_28

    .line 4
    new-instance v0, Ljava/util/ArrayList;

    iget-object v1, p0, Lcom/path/android/jobqueue/RunningJobSet;->internalSet:Ljava/util/TreeSet;

    invoke-direct {v0, v1}, Ljava/util/ArrayList;-><init>(Ljava/util/Collection;)V

    iput-object v0, p0, Lcom/path/android/jobqueue/RunningJobSet;->publicClone:Ljava/util/ArrayList;

    const-wide v0, 0x7fffffffffffffffL

    .line 5
    iput-wide v0, p0, Lcom/path/android/jobqueue/RunningJobSet;->groupDelayTimeout:J

    goto :goto_76

    .line 6
    :cond_28
    new-instance v2, Ljava/util/TreeSet;

    iget-object v3, p0, Lcom/path/android/jobqueue/RunningJobSet;->internalSet:Ljava/util/TreeSet;

    invoke-direct {v2, v3}, Ljava/util/TreeSet;-><init>(Ljava/util/SortedSet;)V

    .line 7
    iget-object v3, p0, Lcom/path/android/jobqueue/RunningJobSet;->groupDelays:Ljava/util/Map;

    invoke-interface {v3}, Ljava/util/Map;->entrySet()Ljava/util/Set;

    move-result-object v3

    invoke-interface {v3}, Ljava/util/Set;->iterator()Ljava/util/Iterator;

    move-result-object v3

    .line 8
    :cond_39
    :goto_39
    invoke-interface {v3}, Ljava/util/Iterator;->hasNext()Z

    move-result v4

    if-eqz v4, :cond_69

    .line 9
    invoke-interface {v3}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v4

    check-cast v4, Ljava/util/Map$Entry;

    .line 10
    invoke-interface {v4}, Ljava/util/Map$Entry;->getValue()Ljava/lang/Object;

    move-result-object v5

    check-cast v5, Ljava/lang/Long;

    invoke-virtual {v5}, Ljava/lang/Long;->longValue()J

    move-result-wide v5

    cmp-long v7, v5, v0

    if-lez v7, :cond_65

    .line 11
    invoke-interface {v4}, Ljava/util/Map$Entry;->getKey()Ljava/lang/Object;

    move-result-object v5

    invoke-virtual {v2, v5}, Ljava/util/TreeSet;->contains(Ljava/lang/Object;)Z

    move-result v5

    if-nez v5, :cond_39

    .line 12
    invoke-interface {v4}, Ljava/util/Map$Entry;->getKey()Ljava/lang/Object;

    move-result-object v4

    invoke-virtual {v2, v4}, Ljava/util/TreeSet;->add(Ljava/lang/Object;)Z

    goto :goto_39

    .line 13
    :cond_65
    invoke-interface {v3}, Ljava/util/Iterator;->remove()V

    goto :goto_39

    .line 14
    :cond_69
    new-instance v0, Ljava/util/ArrayList;

    invoke-direct {v0, v2}, Ljava/util/ArrayList;-><init>(Ljava/util/Collection;)V

    iput-object v0, p0, Lcom/path/android/jobqueue/RunningJobSet;->publicClone:Ljava/util/ArrayList;

    .line 15
    invoke-direct {p0}, Lcom/path/android/jobqueue/RunningJobSet;->calculateNextDelayForGroups()J

    move-result-wide v0

    iput-wide v0, p0, Lcom/path/android/jobqueue/RunningJobSet;->groupDelayTimeout:J

    .line 16
    :cond_76
    :goto_76
    iget-object v0, p0, Lcom/path/android/jobqueue/RunningJobSet;->publicClone:Ljava/util/ArrayList;
    :try_end_78
    .catchall {:try_start_1 .. :try_end_78} :catchall_7a

    monitor-exit p0

    return-object v0

    :catchall_7a
    move-exception v0

    monitor-exit p0

    throw v0
.end method

.method public now()J
    .registers 3

    invoke-static {}, Ljava/lang/System;->nanoTime()J

    move-result-wide v0

    return-wide v0
.end method

.method public declared-synchronized remove(Ljava/lang/String;)V
    .registers 3

    monitor-enter p0

    .line 1
    :try_start_1
    iget-object v0, p0, Lcom/path/android/jobqueue/RunningJobSet;->internalSet:Ljava/util/TreeSet;

    invoke-virtual {v0, p1}, Ljava/util/TreeSet;->remove(Ljava/lang/Object;)Z

    move-result p1

    if-eqz p1, :cond_c

    const/4 p1, 0x0

    .line 2
    iput-object p1, p0, Lcom/path/android/jobqueue/RunningJobSet;->publicClone:Ljava/util/ArrayList;
    :try_end_c
    .catchall {:try_start_1 .. :try_end_c} :catchall_e

    .line 3
    :cond_c
    monitor-exit p0

    return-void

    :catchall_e
    move-exception p1

    monitor-exit p0

    throw p1
.end method