195 lines
4.8 KiB
Smali
195 lines
4.8 KiB
Smali
.class public Landroidx/work/impl/utils/SerialExecutor;
|
|
.super Ljava/lang/Object;
|
|
.source "SerialExecutor.java"
|
|
|
|
# interfaces
|
|
.implements Ljava/util/concurrent/Executor;
|
|
|
|
|
|
# annotations
|
|
.annotation system Ldalvik/annotation/MemberClasses;
|
|
value = {
|
|
Landroidx/work/impl/utils/SerialExecutor$Task;
|
|
}
|
|
.end annotation
|
|
|
|
|
|
# instance fields
|
|
.field public volatile mActive:Ljava/lang/Runnable;
|
|
|
|
.field public final mExecutor:Ljava/util/concurrent/Executor;
|
|
|
|
.field public final mLock:Ljava/lang/Object;
|
|
|
|
.field public final mTasks:Ljava/util/ArrayDeque;
|
|
.annotation system Ldalvik/annotation/Signature;
|
|
value = {
|
|
"Ljava/util/ArrayDeque<",
|
|
"Landroidx/work/impl/utils/SerialExecutor$Task;",
|
|
">;"
|
|
}
|
|
.end annotation
|
|
.end field
|
|
|
|
|
|
# direct methods
|
|
.method public constructor <init>(Ljava/util/concurrent/Executor;)V
|
|
.locals 0
|
|
.param p1 # Ljava/util/concurrent/Executor;
|
|
.annotation build Landroidx/annotation/NonNull;
|
|
.end annotation
|
|
.end param
|
|
|
|
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
|
|
|
|
iput-object p1, p0, Landroidx/work/impl/utils/SerialExecutor;->mExecutor:Ljava/util/concurrent/Executor;
|
|
|
|
new-instance p1, Ljava/util/ArrayDeque;
|
|
|
|
invoke-direct {p1}, Ljava/util/ArrayDeque;-><init>()V
|
|
|
|
iput-object p1, p0, Landroidx/work/impl/utils/SerialExecutor;->mTasks:Ljava/util/ArrayDeque;
|
|
|
|
new-instance p1, Ljava/lang/Object;
|
|
|
|
invoke-direct {p1}, Ljava/lang/Object;-><init>()V
|
|
|
|
iput-object p1, p0, Landroidx/work/impl/utils/SerialExecutor;->mLock:Ljava/lang/Object;
|
|
|
|
return-void
|
|
.end method
|
|
|
|
|
|
# virtual methods
|
|
.method public execute(Ljava/lang/Runnable;)V
|
|
.locals 3
|
|
.param p1 # Ljava/lang/Runnable;
|
|
.annotation build Landroidx/annotation/NonNull;
|
|
.end annotation
|
|
.end param
|
|
|
|
iget-object v0, p0, Landroidx/work/impl/utils/SerialExecutor;->mLock:Ljava/lang/Object;
|
|
|
|
monitor-enter v0
|
|
|
|
:try_start_0
|
|
iget-object v1, p0, Landroidx/work/impl/utils/SerialExecutor;->mTasks:Ljava/util/ArrayDeque;
|
|
|
|
new-instance v2, Landroidx/work/impl/utils/SerialExecutor$Task;
|
|
|
|
invoke-direct {v2, p0, p1}, Landroidx/work/impl/utils/SerialExecutor$Task;-><init>(Landroidx/work/impl/utils/SerialExecutor;Ljava/lang/Runnable;)V
|
|
|
|
invoke-virtual {v1, v2}, Ljava/util/ArrayDeque;->add(Ljava/lang/Object;)Z
|
|
|
|
iget-object p1, p0, Landroidx/work/impl/utils/SerialExecutor;->mActive:Ljava/lang/Runnable;
|
|
|
|
if-nez p1, :cond_0
|
|
|
|
invoke-virtual {p0}, Landroidx/work/impl/utils/SerialExecutor;->scheduleNext()V
|
|
|
|
:cond_0
|
|
monitor-exit v0
|
|
|
|
return-void
|
|
|
|
:catchall_0
|
|
move-exception p1
|
|
|
|
monitor-exit v0
|
|
:try_end_0
|
|
.catchall {:try_start_0 .. :try_end_0} :catchall_0
|
|
|
|
throw p1
|
|
.end method
|
|
|
|
.method public getDelegatedExecutor()Ljava/util/concurrent/Executor;
|
|
.locals 1
|
|
.annotation build Landroidx/annotation/NonNull;
|
|
.end annotation
|
|
|
|
.annotation build Landroidx/annotation/VisibleForTesting;
|
|
.end annotation
|
|
|
|
iget-object v0, p0, Landroidx/work/impl/utils/SerialExecutor;->mExecutor:Ljava/util/concurrent/Executor;
|
|
|
|
return-object v0
|
|
.end method
|
|
|
|
.method public hasPendingTasks()Z
|
|
.locals 2
|
|
|
|
iget-object v0, p0, Landroidx/work/impl/utils/SerialExecutor;->mLock:Ljava/lang/Object;
|
|
|
|
monitor-enter v0
|
|
|
|
:try_start_0
|
|
iget-object v1, p0, Landroidx/work/impl/utils/SerialExecutor;->mTasks:Ljava/util/ArrayDeque;
|
|
|
|
invoke-virtual {v1}, Ljava/util/ArrayDeque;->isEmpty()Z
|
|
|
|
move-result v1
|
|
|
|
if-nez v1, :cond_0
|
|
|
|
const/4 v1, 0x1
|
|
|
|
goto :goto_0
|
|
|
|
:cond_0
|
|
const/4 v1, 0x0
|
|
|
|
:goto_0
|
|
monitor-exit v0
|
|
|
|
return v1
|
|
|
|
:catchall_0
|
|
move-exception v1
|
|
|
|
monitor-exit v0
|
|
:try_end_0
|
|
.catchall {:try_start_0 .. :try_end_0} :catchall_0
|
|
|
|
throw v1
|
|
.end method
|
|
|
|
.method public scheduleNext()V
|
|
.locals 3
|
|
|
|
iget-object v0, p0, Landroidx/work/impl/utils/SerialExecutor;->mLock:Ljava/lang/Object;
|
|
|
|
monitor-enter v0
|
|
|
|
:try_start_0
|
|
iget-object v1, p0, Landroidx/work/impl/utils/SerialExecutor;->mTasks:Ljava/util/ArrayDeque;
|
|
|
|
invoke-virtual {v1}, Ljava/util/ArrayDeque;->poll()Ljava/lang/Object;
|
|
|
|
move-result-object v1
|
|
|
|
check-cast v1, Ljava/lang/Runnable;
|
|
|
|
iput-object v1, p0, Landroidx/work/impl/utils/SerialExecutor;->mActive:Ljava/lang/Runnable;
|
|
|
|
if-eqz v1, :cond_0
|
|
|
|
iget-object v1, p0, Landroidx/work/impl/utils/SerialExecutor;->mExecutor:Ljava/util/concurrent/Executor;
|
|
|
|
iget-object v2, p0, Landroidx/work/impl/utils/SerialExecutor;->mActive:Ljava/lang/Runnable;
|
|
|
|
invoke-interface {v1, v2}, Ljava/util/concurrent/Executor;->execute(Ljava/lang/Runnable;)V
|
|
|
|
:cond_0
|
|
monitor-exit v0
|
|
|
|
return-void
|
|
|
|
:catchall_0
|
|
move-exception v1
|
|
|
|
monitor-exit v0
|
|
:try_end_0
|
|
.catchall {:try_start_0 .. :try_end_0} :catchall_0
|
|
|
|
throw v1
|
|
.end method
|