.class Lcom/badlogic/gdx/utils/Timer$TimerThread;
.super Ljava/lang/Object;
.source "Timer.java"

# interfaces
.implements Lcom/badlogic/gdx/LifecycleListener;
.implements Ljava/lang/Runnable;


# annotations
.annotation system Ldalvik/annotation/EnclosingClass;
    value = Lcom/badlogic/gdx/utils/Timer;
.end annotation

.annotation system Ldalvik/annotation/InnerClass;
    accessFlags = 0x8
    name = "TimerThread"
.end annotation


# instance fields
.field a:Lcom/badlogic/gdx/Files;

.field private b:J


# direct methods
.method public constructor <init>()V
    .locals 1

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

    .line 235
    sget-object v0, Lcom/badlogic/gdx/Gdx;->a:Lcom/badlogic/gdx/Application;

    invoke-interface {v0, p0}, Lcom/badlogic/gdx/Application;->addLifecycleListener(Lcom/badlogic/gdx/LifecycleListener;)V

    .line 236
    invoke-virtual {p0}, Lcom/badlogic/gdx/utils/Timer$TimerThread;->b()V

    return-void
.end method


# virtual methods
.method public a()V
    .locals 4

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

    move-result-wide v0

    const-wide/32 v2, 0xf4240

    div-long/2addr v0, v2

    iput-wide v0, p0, Lcom/badlogic/gdx/utils/Timer$TimerThread;->b:J

    .line 280
    sget-object v0, Lcom/badlogic/gdx/utils/Timer;->a:Lcom/badlogic/gdx/utils/Array;

    monitor-enter v0

    const/4 v1, 0x0

    .line 281
    :try_start_0
    iput-object v1, p0, Lcom/badlogic/gdx/utils/Timer$TimerThread;->a:Lcom/badlogic/gdx/Files;

    .line 282
    invoke-static {}, Lcom/badlogic/gdx/utils/Timer;->c()V

    .line 283
    monitor-exit v0
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    .line 284
    sput-object v1, Lcom/badlogic/gdx/utils/Timer;->b:Lcom/badlogic/gdx/utils/Timer$TimerThread;

    return-void

    :catchall_0
    move-exception v1

    .line 283
    :try_start_1
    monitor-exit v0
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_0

    throw v1
.end method

.method public b()V
    .locals 6

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

    move-result-wide v0

    const-wide/32 v2, 0xf4240

    div-long/2addr v0, v2

    iget-wide v2, p0, Lcom/badlogic/gdx/utils/Timer$TimerThread;->b:J

    sub-long/2addr v0, v2

    .line 266
    sget-object v2, Lcom/badlogic/gdx/utils/Timer;->a:Lcom/badlogic/gdx/utils/Array;

    monitor-enter v2

    const/4 v3, 0x0

    .line 267
    :try_start_0
    sget-object v4, Lcom/badlogic/gdx/utils/Timer;->a:Lcom/badlogic/gdx/utils/Array;

    iget v4, v4, Lcom/badlogic/gdx/utils/Array;->b:I

    :goto_0
    if-ge v3, v4, :cond_0

    .line 268
    sget-object v5, Lcom/badlogic/gdx/utils/Timer;->a:Lcom/badlogic/gdx/utils/Array;

    invoke-virtual {v5, v3}, Lcom/badlogic/gdx/utils/Array;->a(I)Ljava/lang/Object;

    move-result-object v5

    check-cast v5, Lcom/badlogic/gdx/utils/Timer;

    invoke-virtual {v5, v0, v1}, Lcom/badlogic/gdx/utils/Timer;->a(J)V

    add-int/lit8 v3, v3, 0x1

    goto :goto_0

    .line 270
    :cond_0
    monitor-exit v2
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    .line 271
    sget-object v0, Lcom/badlogic/gdx/Gdx;->d:Lcom/badlogic/gdx/Files;

    iput-object v0, p0, Lcom/badlogic/gdx/utils/Timer$TimerThread;->a:Lcom/badlogic/gdx/Files;

    .line 272
    new-instance v0, Ljava/lang/Thread;

    const-string v1, "Timer"

    invoke-direct {v0, p0, v1}, Ljava/lang/Thread;-><init>(Ljava/lang/Runnable;Ljava/lang/String;)V

    const/4 v1, 0x1

    .line 273
    invoke-virtual {v0, v1}, Ljava/lang/Thread;->setDaemon(Z)V

    .line 274
    invoke-virtual {v0}, Ljava/lang/Thread;->start()V

    .line 275
    sput-object p0, Lcom/badlogic/gdx/utils/Timer;->b:Lcom/badlogic/gdx/utils/Timer$TimerThread;

    return-void

    :catchall_0
    move-exception v0

    .line 270
    :try_start_1
    monitor-exit v2
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_0

    throw v0
.end method

.method public c()V
    .locals 1

    .line 288
    invoke-virtual {p0}, Lcom/badlogic/gdx/utils/Timer$TimerThread;->a()V

    .line 289
    sget-object v0, Lcom/badlogic/gdx/Gdx;->a:Lcom/badlogic/gdx/Application;

    invoke-interface {v0, p0}, Lcom/badlogic/gdx/Application;->removeLifecycleListener(Lcom/badlogic/gdx/LifecycleListener;)V

    .line 290
    sget-object v0, Lcom/badlogic/gdx/utils/Timer;->a:Lcom/badlogic/gdx/utils/Array;

    invoke-virtual {v0}, Lcom/badlogic/gdx/utils/Array;->d()V

    const/4 v0, 0x0

    .line 291
    sput-object v0, Lcom/badlogic/gdx/utils/Timer;->c:Lcom/badlogic/gdx/utils/Timer;

    return-void
.end method

.method public run()V
    .locals 8

    .line 241
    :goto_0
    sget-object v0, Lcom/badlogic/gdx/utils/Timer;->a:Lcom/badlogic/gdx/utils/Array;

    monitor-enter v0

    .line 242
    :try_start_0
    iget-object v1, p0, Lcom/badlogic/gdx/utils/Timer$TimerThread;->a:Lcom/badlogic/gdx/Files;

    sget-object v2, Lcom/badlogic/gdx/Gdx;->d:Lcom/badlogic/gdx/Files;

    if-eq v1, v2, :cond_0

    monitor-exit v0

    return-void

    .line 244
    :cond_0
    invoke-static {}, Ljava/lang/System;->nanoTime()J

    move-result-wide v1

    const-wide/32 v3, 0xf4240

    div-long/2addr v1, v3

    const-wide/16 v3, 0x1388

    const/4 v5, 0x0

    .line 246
    sget-object v6, Lcom/badlogic/gdx/utils/Timer;->a:Lcom/badlogic/gdx/utils/Array;

    iget v6, v6, Lcom/badlogic/gdx/utils/Array;->b:I
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    :goto_1
    if-ge v5, v6, :cond_1

    .line 248
    :try_start_1
    sget-object v7, Lcom/badlogic/gdx/utils/Timer;->a:Lcom/badlogic/gdx/utils/Array;

    invoke-virtual {v7, v5}, Lcom/badlogic/gdx/utils/Array;->a(I)Ljava/lang/Object;

    move-result-object v7

    check-cast v7, Lcom/badlogic/gdx/utils/Timer;

    invoke-virtual {v7, v1, v2, v3, v4}, Lcom/badlogic/gdx/utils/Timer;->a(JJ)J

    move-result-wide v3
    :try_end_1
    .catch Ljava/lang/Throwable; {:try_start_1 .. :try_end_1} :catch_0
    .catchall {:try_start_1 .. :try_end_1} :catchall_0

    add-int/lit8 v5, v5, 0x1

    goto :goto_1

    :catch_0
    move-exception v1

    .line 250
    :try_start_2
    new-instance v2, Lcom/badlogic/gdx/utils/GdxRuntimeException;

    new-instance v3, Ljava/lang/StringBuilder;

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

    const-string v4, "Task failed: "

    invoke-virtual {v3, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    sget-object v4, Lcom/badlogic/gdx/utils/Timer;->a:Lcom/badlogic/gdx/utils/Array;

    invoke-virtual {v4, v5}, Lcom/badlogic/gdx/utils/Array;->a(I)Ljava/lang/Object;

    move-result-object v4

    check-cast v4, Lcom/badlogic/gdx/utils/Timer;

    invoke-virtual {v4}, Ljava/lang/Object;->getClass()Ljava/lang/Class;

    move-result-object v4

    invoke-virtual {v4}, Ljava/lang/Class;->getName()Ljava/lang/String;

    move-result-object v4

    invoke-virtual {v3, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    invoke-virtual {v3}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v3

    invoke-direct {v2, v3, v1}, Lcom/badlogic/gdx/utils/GdxRuntimeException;-><init>(Ljava/lang/String;Ljava/lang/Throwable;)V

    throw v2

    .line 254
    :cond_1
    iget-object v1, p0, Lcom/badlogic/gdx/utils/Timer$TimerThread;->a:Lcom/badlogic/gdx/Files;

    sget-object v2, Lcom/badlogic/gdx/Gdx;->d:Lcom/badlogic/gdx/Files;

    if-eq v1, v2, :cond_2

    monitor-exit v0
    :try_end_2
    .catchall {:try_start_2 .. :try_end_2} :catchall_0

    return-void

    :cond_2
    const-wide/16 v1, 0x0

    cmp-long v5, v3, v1

    if-lez v5, :cond_3

    .line 257
    :try_start_3
    sget-object v1, Lcom/badlogic/gdx/utils/Timer;->a:Lcom/badlogic/gdx/utils/Array;

    invoke-virtual {v1, v3, v4}, Ljava/lang/Object;->wait(J)V
    :try_end_3
    .catch Ljava/lang/InterruptedException; {:try_start_3 .. :try_end_3} :catch_1
    .catchall {:try_start_3 .. :try_end_3} :catchall_0

    .line 260
    :catch_1
    :cond_3
    :try_start_4
    monitor-exit v0

    goto :goto_0

    :catchall_0
    move-exception v1

    monitor-exit v0
    :try_end_4
    .catchall {:try_start_4 .. :try_end_4} :catchall_0

    throw v1
.end method
