tmap/smali_classes3/com/google/common/util/concurrent/CycleDetectingLockFactory.smali
2022-06-10 21:38:30 +09:00

628 lines
21 KiB
Smali

.class public Lcom/google/common/util/concurrent/CycleDetectingLockFactory;
.super Ljava/lang/Object;
.source "CycleDetectingLockFactory.java"
# annotations
.annotation build Lcom/google/common/annotations/Beta;
.end annotation
.annotation build Lcom/google/common/annotations/GwtIncompatible;
.end annotation
.annotation runtime Lcom/google/common/util/concurrent/ElementTypesAreNonnullByDefault;
.end annotation
.annotation build Lcom/google/errorprone/annotations/CanIgnoreReturnValue;
.end annotation
.annotation system Ldalvik/annotation/MemberClasses;
value = {
Lcom/google/common/util/concurrent/CycleDetectingLockFactory$CycleDetectingReentrantWriteLock;,
Lcom/google/common/util/concurrent/CycleDetectingLockFactory$CycleDetectingReentrantReadLock;,
Lcom/google/common/util/concurrent/CycleDetectingLockFactory$CycleDetectingReentrantReadWriteLock;,
Lcom/google/common/util/concurrent/CycleDetectingLockFactory$CycleDetectingReentrantLock;,
Lcom/google/common/util/concurrent/CycleDetectingLockFactory$LockGraphNode;,
Lcom/google/common/util/concurrent/CycleDetectingLockFactory$CycleDetectingLock;,
Lcom/google/common/util/concurrent/CycleDetectingLockFactory$PotentialDeadlockException;,
Lcom/google/common/util/concurrent/CycleDetectingLockFactory$ExampleStackTrace;,
Lcom/google/common/util/concurrent/CycleDetectingLockFactory$WithExplicitOrdering;,
Lcom/google/common/util/concurrent/CycleDetectingLockFactory$Policies;,
Lcom/google/common/util/concurrent/CycleDetectingLockFactory$Policy;
}
.end annotation
# static fields
.field private static final acquiredLocks:Ljava/lang/ThreadLocal;
.annotation system Ldalvik/annotation/Signature;
value = {
"Ljava/lang/ThreadLocal<",
"Ljava/util/ArrayList<",
"Lcom/google/common/util/concurrent/CycleDetectingLockFactory$LockGraphNode;",
">;>;"
}
.end annotation
.end field
.field private static final lockGraphNodesPerType:Ljava/util/concurrent/ConcurrentMap;
.annotation system Ldalvik/annotation/Signature;
value = {
"Ljava/util/concurrent/ConcurrentMap<",
"Ljava/lang/Class<",
"+",
"Ljava/lang/Enum<",
"*>;>;",
"Ljava/util/Map<",
"+",
"Ljava/lang/Enum<",
"*>;",
"Lcom/google/common/util/concurrent/CycleDetectingLockFactory$LockGraphNode;",
">;>;"
}
.end annotation
.end field
.field private static final logger:Ljava/util/logging/Logger;
# instance fields
.field public final policy:Lcom/google/common/util/concurrent/CycleDetectingLockFactory$Policy;
# direct methods
.method public static constructor <clinit>()V
.locals 1
.line 1
new-instance v0, Lcom/google/common/collect/MapMaker;
invoke-direct {v0}, Lcom/google/common/collect/MapMaker;-><init>()V
invoke-virtual {v0}, Lcom/google/common/collect/MapMaker;->weakKeys()Lcom/google/common/collect/MapMaker;
move-result-object v0
invoke-virtual {v0}, Lcom/google/common/collect/MapMaker;->makeMap()Ljava/util/concurrent/ConcurrentMap;
move-result-object v0
sput-object v0, Lcom/google/common/util/concurrent/CycleDetectingLockFactory;->lockGraphNodesPerType:Ljava/util/concurrent/ConcurrentMap;
.line 2
const-class v0, Lcom/google/common/util/concurrent/CycleDetectingLockFactory;
invoke-virtual {v0}, Ljava/lang/Class;->getName()Ljava/lang/String;
move-result-object v0
invoke-static {v0}, Ljava/util/logging/Logger;->getLogger(Ljava/lang/String;)Ljava/util/logging/Logger;
move-result-object v0
sput-object v0, Lcom/google/common/util/concurrent/CycleDetectingLockFactory;->logger:Ljava/util/logging/Logger;
.line 3
new-instance v0, Lcom/google/common/util/concurrent/CycleDetectingLockFactory$1;
invoke-direct {v0}, Lcom/google/common/util/concurrent/CycleDetectingLockFactory$1;-><init>()V
sput-object v0, Lcom/google/common/util/concurrent/CycleDetectingLockFactory;->acquiredLocks:Ljava/lang/ThreadLocal;
return-void
.end method
.method private constructor <init>(Lcom/google/common/util/concurrent/CycleDetectingLockFactory$Policy;)V
.locals 0
.line 2
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
.line 3
invoke-static {p1}, Lcom/google/common/base/Preconditions;->checkNotNull(Ljava/lang/Object;)Ljava/lang/Object;
move-result-object p1
check-cast p1, Lcom/google/common/util/concurrent/CycleDetectingLockFactory$Policy;
iput-object p1, p0, Lcom/google/common/util/concurrent/CycleDetectingLockFactory;->policy:Lcom/google/common/util/concurrent/CycleDetectingLockFactory$Policy;
return-void
.end method
.method public synthetic constructor <init>(Lcom/google/common/util/concurrent/CycleDetectingLockFactory$Policy;Lcom/google/common/util/concurrent/CycleDetectingLockFactory$1;)V
.locals 0
.line 1
invoke-direct {p0, p1}, Lcom/google/common/util/concurrent/CycleDetectingLockFactory;-><init>(Lcom/google/common/util/concurrent/CycleDetectingLockFactory$Policy;)V
return-void
.end method
.method private aboutToAcquire(Lcom/google/common/util/concurrent/CycleDetectingLockFactory$CycleDetectingLock;)V
.locals 2
.line 1
invoke-interface {p1}, Lcom/google/common/util/concurrent/CycleDetectingLockFactory$CycleDetectingLock;->isAcquiredByCurrentThread()Z
move-result v0
if-nez v0, :cond_0
.line 2
sget-object v0, Lcom/google/common/util/concurrent/CycleDetectingLockFactory;->acquiredLocks:Ljava/lang/ThreadLocal;
invoke-virtual {v0}, Ljava/lang/ThreadLocal;->get()Ljava/lang/Object;
move-result-object v0
check-cast v0, Ljava/util/ArrayList;
.line 3
invoke-interface {p1}, Lcom/google/common/util/concurrent/CycleDetectingLockFactory$CycleDetectingLock;->getLockGraphNode()Lcom/google/common/util/concurrent/CycleDetectingLockFactory$LockGraphNode;
move-result-object p1
.line 4
iget-object v1, p0, Lcom/google/common/util/concurrent/CycleDetectingLockFactory;->policy:Lcom/google/common/util/concurrent/CycleDetectingLockFactory$Policy;
invoke-virtual {p1, v1, v0}, Lcom/google/common/util/concurrent/CycleDetectingLockFactory$LockGraphNode;->checkAcquiredLocks(Lcom/google/common/util/concurrent/CycleDetectingLockFactory$Policy;Ljava/util/List;)V
.line 5
invoke-virtual {v0, p1}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z
:cond_0
return-void
.end method
.method public static synthetic access$100()Ljava/util/logging/Logger;
.locals 1
.line 1
sget-object v0, Lcom/google/common/util/concurrent/CycleDetectingLockFactory;->logger:Ljava/util/logging/Logger;
return-object v0
.end method
.method public static synthetic access$600(Lcom/google/common/util/concurrent/CycleDetectingLockFactory;Lcom/google/common/util/concurrent/CycleDetectingLockFactory$CycleDetectingLock;)V
.locals 0
.line 1
invoke-direct {p0, p1}, Lcom/google/common/util/concurrent/CycleDetectingLockFactory;->aboutToAcquire(Lcom/google/common/util/concurrent/CycleDetectingLockFactory$CycleDetectingLock;)V
return-void
.end method
.method public static synthetic access$700(Lcom/google/common/util/concurrent/CycleDetectingLockFactory$CycleDetectingLock;)V
.locals 0
.line 1
invoke-static {p0}, Lcom/google/common/util/concurrent/CycleDetectingLockFactory;->lockStateChanged(Lcom/google/common/util/concurrent/CycleDetectingLockFactory$CycleDetectingLock;)V
return-void
.end method
.method public static createNodes(Ljava/lang/Class;)Ljava/util/Map;
.locals 9
.annotation build Lcom/google/common/annotations/VisibleForTesting;
.end annotation
.annotation system Ldalvik/annotation/Signature;
value = {
"<E:",
"Ljava/lang/Enum<",
"TE;>;>(",
"Ljava/lang/Class<",
"TE;>;)",
"Ljava/util/Map<",
"TE;",
"Lcom/google/common/util/concurrent/CycleDetectingLockFactory$LockGraphNode;",
">;"
}
.end annotation
.line 1
invoke-static {p0}, Lcom/google/common/collect/Maps;->newEnumMap(Ljava/lang/Class;)Ljava/util/EnumMap;
move-result-object v0
.line 2
invoke-virtual {p0}, Ljava/lang/Class;->getEnumConstants()[Ljava/lang/Object;
move-result-object p0
check-cast p0, [Ljava/lang/Enum;
.line 3
array-length v1, p0
.line 4
invoke-static {v1}, Lcom/google/common/collect/Lists;->newArrayListWithCapacity(I)Ljava/util/ArrayList;
move-result-object v2
.line 5
array-length v3, p0
const/4 v4, 0x0
move v5, v4
:goto_0
if-ge v5, v3, :cond_0
aget-object v6, p0, v5
.line 6
new-instance v7, Lcom/google/common/util/concurrent/CycleDetectingLockFactory$LockGraphNode;
invoke-static {v6}, Lcom/google/common/util/concurrent/CycleDetectingLockFactory;->getLockName(Ljava/lang/Enum;)Ljava/lang/String;
move-result-object v8
invoke-direct {v7, v8}, Lcom/google/common/util/concurrent/CycleDetectingLockFactory$LockGraphNode;-><init>(Ljava/lang/String;)V
.line 7
invoke-virtual {v2, v7}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z
.line 8
invoke-virtual {v0, v6, v7}, Ljava/util/EnumMap;->put(Ljava/lang/Enum;Ljava/lang/Object;)Ljava/lang/Object;
add-int/lit8 v5, v5, 0x1
goto :goto_0
:cond_0
const/4 p0, 0x1
:goto_1
if-ge p0, v1, :cond_1
.line 9
invoke-virtual {v2, p0}, Ljava/util/ArrayList;->get(I)Ljava/lang/Object;
move-result-object v3
check-cast v3, Lcom/google/common/util/concurrent/CycleDetectingLockFactory$LockGraphNode;
sget-object v5, Lcom/google/common/util/concurrent/CycleDetectingLockFactory$Policies;->THROW:Lcom/google/common/util/concurrent/CycleDetectingLockFactory$Policies;
invoke-virtual {v2, v4, p0}, Ljava/util/ArrayList;->subList(II)Ljava/util/List;
move-result-object v6
invoke-virtual {v3, v5, v6}, Lcom/google/common/util/concurrent/CycleDetectingLockFactory$LockGraphNode;->checkAcquiredLocks(Lcom/google/common/util/concurrent/CycleDetectingLockFactory$Policy;Ljava/util/List;)V
add-int/lit8 p0, p0, 0x1
goto :goto_1
:cond_1
:goto_2
add-int/lit8 p0, v1, -0x1
if-ge v4, p0, :cond_2
.line 10
invoke-virtual {v2, v4}, Ljava/util/ArrayList;->get(I)Ljava/lang/Object;
move-result-object p0
check-cast p0, Lcom/google/common/util/concurrent/CycleDetectingLockFactory$LockGraphNode;
sget-object v3, Lcom/google/common/util/concurrent/CycleDetectingLockFactory$Policies;->DISABLED:Lcom/google/common/util/concurrent/CycleDetectingLockFactory$Policies;
add-int/lit8 v4, v4, 0x1
invoke-virtual {v2, v4, v1}, Ljava/util/ArrayList;->subList(II)Ljava/util/List;
move-result-object v5
invoke-virtual {p0, v3, v5}, Lcom/google/common/util/concurrent/CycleDetectingLockFactory$LockGraphNode;->checkAcquiredLocks(Lcom/google/common/util/concurrent/CycleDetectingLockFactory$Policy;Ljava/util/List;)V
goto :goto_2
.line 11
:cond_2
invoke-static {v0}, Ljava/util/Collections;->unmodifiableMap(Ljava/util/Map;)Ljava/util/Map;
move-result-object p0
return-object p0
.end method
.method private static getLockName(Ljava/lang/Enum;)Ljava/lang/String;
.locals 3
.annotation system Ldalvik/annotation/Signature;
value = {
"(",
"Ljava/lang/Enum<",
"*>;)",
"Ljava/lang/String;"
}
.end annotation
.line 1
invoke-virtual {p0}, Ljava/lang/Enum;->getDeclaringClass()Ljava/lang/Class;
move-result-object v0
invoke-virtual {v0}, Ljava/lang/Class;->getSimpleName()Ljava/lang/String;
move-result-object v0
invoke-virtual {p0}, Ljava/lang/Enum;->name()Ljava/lang/String;
move-result-object p0
invoke-virtual {v0}, Ljava/lang/String;->length()I
move-result v1
add-int/lit8 v1, v1, 0x1
invoke-static {p0, v1}, Lcom/android/billingclient/api/d;->a(Ljava/lang/String;I)I
move-result v1
const-string v2, "."
invoke-static {v1, v0, v2, p0}, Lcom/google/android/gms/ads/internal/a;->a(ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
move-result-object p0
return-object p0
.end method
.method private static getOrCreateNodes(Ljava/lang/Class;)Ljava/util/Map;
.locals 2
.annotation system Ldalvik/annotation/Signature;
value = {
"<E:",
"Ljava/lang/Enum<",
"TE;>;>(",
"Ljava/lang/Class<",
"TE;>;)",
"Ljava/util/Map<",
"+TE;",
"Lcom/google/common/util/concurrent/CycleDetectingLockFactory$LockGraphNode;",
">;"
}
.end annotation
.line 1
sget-object v0, Lcom/google/common/util/concurrent/CycleDetectingLockFactory;->lockGraphNodesPerType:Ljava/util/concurrent/ConcurrentMap;
invoke-interface {v0, p0}, Ljava/util/concurrent/ConcurrentMap;->get(Ljava/lang/Object;)Ljava/lang/Object;
move-result-object v1
check-cast v1, Ljava/util/Map;
if-eqz v1, :cond_0
return-object v1
.line 2
:cond_0
invoke-static {p0}, Lcom/google/common/util/concurrent/CycleDetectingLockFactory;->createNodes(Ljava/lang/Class;)Ljava/util/Map;
move-result-object v1
.line 3
invoke-interface {v0, p0, v1}, Ljava/util/concurrent/ConcurrentMap;->putIfAbsent(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
move-result-object p0
check-cast p0, Ljava/util/Map;
.line 4
invoke-static {p0, v1}, Lcom/google/common/base/MoreObjects;->firstNonNull(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
move-result-object p0
check-cast p0, Ljava/util/Map;
return-object p0
.end method
.method private static lockStateChanged(Lcom/google/common/util/concurrent/CycleDetectingLockFactory$CycleDetectingLock;)V
.locals 3
.line 1
invoke-interface {p0}, Lcom/google/common/util/concurrent/CycleDetectingLockFactory$CycleDetectingLock;->isAcquiredByCurrentThread()Z
move-result v0
if-nez v0, :cond_1
.line 2
sget-object v0, Lcom/google/common/util/concurrent/CycleDetectingLockFactory;->acquiredLocks:Ljava/lang/ThreadLocal;
invoke-virtual {v0}, Ljava/lang/ThreadLocal;->get()Ljava/lang/Object;
move-result-object v0
check-cast v0, Ljava/util/ArrayList;
.line 3
invoke-interface {p0}, Lcom/google/common/util/concurrent/CycleDetectingLockFactory$CycleDetectingLock;->getLockGraphNode()Lcom/google/common/util/concurrent/CycleDetectingLockFactory$LockGraphNode;
move-result-object p0
.line 4
invoke-virtual {v0}, Ljava/util/ArrayList;->size()I
move-result v1
add-int/lit8 v1, v1, -0x1
:goto_0
if-ltz v1, :cond_1
.line 5
invoke-virtual {v0, v1}, Ljava/util/ArrayList;->get(I)Ljava/lang/Object;
move-result-object v2
if-ne v2, p0, :cond_0
.line 6
invoke-virtual {v0, v1}, Ljava/util/ArrayList;->remove(I)Ljava/lang/Object;
goto :goto_1
:cond_0
add-int/lit8 v1, v1, -0x1
goto :goto_0
:cond_1
:goto_1
return-void
.end method
.method public static newInstance(Lcom/google/common/util/concurrent/CycleDetectingLockFactory$Policy;)Lcom/google/common/util/concurrent/CycleDetectingLockFactory;
.locals 1
.line 1
new-instance v0, Lcom/google/common/util/concurrent/CycleDetectingLockFactory;
invoke-direct {v0, p0}, Lcom/google/common/util/concurrent/CycleDetectingLockFactory;-><init>(Lcom/google/common/util/concurrent/CycleDetectingLockFactory$Policy;)V
return-object v0
.end method
.method public static newInstanceWithExplicitOrdering(Ljava/lang/Class;Lcom/google/common/util/concurrent/CycleDetectingLockFactory$Policy;)Lcom/google/common/util/concurrent/CycleDetectingLockFactory$WithExplicitOrdering;
.locals 1
.annotation system Ldalvik/annotation/Signature;
value = {
"<E:",
"Ljava/lang/Enum<",
"TE;>;>(",
"Ljava/lang/Class<",
"TE;>;",
"Lcom/google/common/util/concurrent/CycleDetectingLockFactory$Policy;",
")",
"Lcom/google/common/util/concurrent/CycleDetectingLockFactory$WithExplicitOrdering<",
"TE;>;"
}
.end annotation
.line 1
invoke-static {p0}, Lcom/google/common/base/Preconditions;->checkNotNull(Ljava/lang/Object;)Ljava/lang/Object;
.line 2
invoke-static {p1}, Lcom/google/common/base/Preconditions;->checkNotNull(Ljava/lang/Object;)Ljava/lang/Object;
.line 3
invoke-static {p0}, Lcom/google/common/util/concurrent/CycleDetectingLockFactory;->getOrCreateNodes(Ljava/lang/Class;)Ljava/util/Map;
move-result-object p0
.line 4
new-instance v0, Lcom/google/common/util/concurrent/CycleDetectingLockFactory$WithExplicitOrdering;
invoke-direct {v0, p1, p0}, Lcom/google/common/util/concurrent/CycleDetectingLockFactory$WithExplicitOrdering;-><init>(Lcom/google/common/util/concurrent/CycleDetectingLockFactory$Policy;Ljava/util/Map;)V
return-object v0
.end method
# virtual methods
.method public newReentrantLock(Ljava/lang/String;)Ljava/util/concurrent/locks/ReentrantLock;
.locals 1
const/4 v0, 0x0
.line 1
invoke-virtual {p0, p1, v0}, Lcom/google/common/util/concurrent/CycleDetectingLockFactory;->newReentrantLock(Ljava/lang/String;Z)Ljava/util/concurrent/locks/ReentrantLock;
move-result-object p1
return-object p1
.end method
.method public newReentrantLock(Ljava/lang/String;Z)Ljava/util/concurrent/locks/ReentrantLock;
.locals 2
.line 2
iget-object v0, p0, Lcom/google/common/util/concurrent/CycleDetectingLockFactory;->policy:Lcom/google/common/util/concurrent/CycleDetectingLockFactory$Policy;
sget-object v1, Lcom/google/common/util/concurrent/CycleDetectingLockFactory$Policies;->DISABLED:Lcom/google/common/util/concurrent/CycleDetectingLockFactory$Policies;
if-ne v0, v1, :cond_0
.line 3
new-instance p1, Ljava/util/concurrent/locks/ReentrantLock;
invoke-direct {p1, p2}, Ljava/util/concurrent/locks/ReentrantLock;-><init>(Z)V
goto :goto_0
.line 4
:cond_0
new-instance v0, Lcom/google/common/util/concurrent/CycleDetectingLockFactory$CycleDetectingReentrantLock;
new-instance v1, Lcom/google/common/util/concurrent/CycleDetectingLockFactory$LockGraphNode;
invoke-direct {v1, p1}, Lcom/google/common/util/concurrent/CycleDetectingLockFactory$LockGraphNode;-><init>(Ljava/lang/String;)V
const/4 p1, 0x0
invoke-direct {v0, p0, v1, p2, p1}, Lcom/google/common/util/concurrent/CycleDetectingLockFactory$CycleDetectingReentrantLock;-><init>(Lcom/google/common/util/concurrent/CycleDetectingLockFactory;Lcom/google/common/util/concurrent/CycleDetectingLockFactory$LockGraphNode;ZLcom/google/common/util/concurrent/CycleDetectingLockFactory$1;)V
move-object p1, v0
:goto_0
return-object p1
.end method
.method public newReentrantReadWriteLock(Ljava/lang/String;)Ljava/util/concurrent/locks/ReentrantReadWriteLock;
.locals 1
const/4 v0, 0x0
.line 1
invoke-virtual {p0, p1, v0}, Lcom/google/common/util/concurrent/CycleDetectingLockFactory;->newReentrantReadWriteLock(Ljava/lang/String;Z)Ljava/util/concurrent/locks/ReentrantReadWriteLock;
move-result-object p1
return-object p1
.end method
.method public newReentrantReadWriteLock(Ljava/lang/String;Z)Ljava/util/concurrent/locks/ReentrantReadWriteLock;
.locals 2
.line 2
iget-object v0, p0, Lcom/google/common/util/concurrent/CycleDetectingLockFactory;->policy:Lcom/google/common/util/concurrent/CycleDetectingLockFactory$Policy;
sget-object v1, Lcom/google/common/util/concurrent/CycleDetectingLockFactory$Policies;->DISABLED:Lcom/google/common/util/concurrent/CycleDetectingLockFactory$Policies;
if-ne v0, v1, :cond_0
.line 3
new-instance p1, Ljava/util/concurrent/locks/ReentrantReadWriteLock;
invoke-direct {p1, p2}, Ljava/util/concurrent/locks/ReentrantReadWriteLock;-><init>(Z)V
goto :goto_0
.line 4
:cond_0
new-instance v0, Lcom/google/common/util/concurrent/CycleDetectingLockFactory$CycleDetectingReentrantReadWriteLock;
new-instance v1, Lcom/google/common/util/concurrent/CycleDetectingLockFactory$LockGraphNode;
invoke-direct {v1, p1}, Lcom/google/common/util/concurrent/CycleDetectingLockFactory$LockGraphNode;-><init>(Ljava/lang/String;)V
const/4 p1, 0x0
invoke-direct {v0, p0, v1, p2, p1}, Lcom/google/common/util/concurrent/CycleDetectingLockFactory$CycleDetectingReentrantReadWriteLock;-><init>(Lcom/google/common/util/concurrent/CycleDetectingLockFactory;Lcom/google/common/util/concurrent/CycleDetectingLockFactory$LockGraphNode;ZLcom/google/common/util/concurrent/CycleDetectingLockFactory$1;)V
move-object p1, v0
:goto_0
return-object p1
.end method