204 lines
5.4 KiB
Java
204 lines
5.4 KiB
Java
package com.google.android.gms.tasks;
|
|
|
|
import com.google.android.gms.common.internal.Preconditions;
|
|
import java.util.concurrent.CancellationException;
|
|
import java.util.concurrent.Executor;
|
|
|
|
/* loaded from: classes.dex */
|
|
final class zzu<TResult> extends Task<TResult> {
|
|
private final Object a = new Object();
|
|
private final zzr<TResult> b = new zzr<>();
|
|
private boolean c;
|
|
private volatile boolean d;
|
|
private TResult e;
|
|
private Exception f;
|
|
|
|
zzu() {
|
|
}
|
|
|
|
private final void g() {
|
|
Preconditions.b(this.c, "Task is not yet complete");
|
|
}
|
|
|
|
private final void h() {
|
|
Preconditions.b(!this.c, "Task is already complete");
|
|
}
|
|
|
|
private final void i() {
|
|
if (this.d) {
|
|
throw new CancellationException("Task is already canceled.");
|
|
}
|
|
}
|
|
|
|
private final void j() {
|
|
synchronized (this.a) {
|
|
if (this.c) {
|
|
this.b.a(this);
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override // com.google.android.gms.tasks.Task
|
|
public final <X extends Throwable> TResult a(Class<X> cls) throws Throwable {
|
|
TResult tresult;
|
|
synchronized (this.a) {
|
|
g();
|
|
i();
|
|
if (cls.isInstance(this.f)) {
|
|
throw cls.cast(this.f);
|
|
}
|
|
if (this.f != null) {
|
|
throw new RuntimeExecutionException(this.f);
|
|
}
|
|
tresult = this.e;
|
|
}
|
|
return tresult;
|
|
}
|
|
|
|
@Override // com.google.android.gms.tasks.Task
|
|
public final TResult b() {
|
|
TResult tresult;
|
|
synchronized (this.a) {
|
|
g();
|
|
i();
|
|
if (this.f != null) {
|
|
throw new RuntimeExecutionException(this.f);
|
|
}
|
|
tresult = this.e;
|
|
}
|
|
return tresult;
|
|
}
|
|
|
|
@Override // com.google.android.gms.tasks.Task
|
|
public final boolean c() {
|
|
return this.d;
|
|
}
|
|
|
|
@Override // com.google.android.gms.tasks.Task
|
|
public final boolean d() {
|
|
boolean z;
|
|
synchronized (this.a) {
|
|
z = this.c;
|
|
}
|
|
return z;
|
|
}
|
|
|
|
@Override // com.google.android.gms.tasks.Task
|
|
public final boolean e() {
|
|
boolean z;
|
|
synchronized (this.a) {
|
|
z = this.c && !this.d && this.f == null;
|
|
}
|
|
return z;
|
|
}
|
|
|
|
public final boolean f() {
|
|
synchronized (this.a) {
|
|
if (this.c) {
|
|
return false;
|
|
}
|
|
this.c = true;
|
|
this.d = true;
|
|
this.b.a(this);
|
|
return true;
|
|
}
|
|
}
|
|
|
|
@Override // com.google.android.gms.tasks.Task
|
|
public final <TContinuationResult> Task<TContinuationResult> b(Executor executor, Continuation<TResult, Task<TContinuationResult>> continuation) {
|
|
zzu zzuVar = new zzu();
|
|
this.b.a(new zze(executor, continuation, zzuVar));
|
|
j();
|
|
return zzuVar;
|
|
}
|
|
|
|
@Override // com.google.android.gms.tasks.Task
|
|
public final Exception a() {
|
|
Exception exc;
|
|
synchronized (this.a) {
|
|
exc = this.f;
|
|
}
|
|
return exc;
|
|
}
|
|
|
|
public final boolean b(TResult tresult) {
|
|
synchronized (this.a) {
|
|
if (this.c) {
|
|
return false;
|
|
}
|
|
this.c = true;
|
|
this.e = tresult;
|
|
this.b.a(this);
|
|
return true;
|
|
}
|
|
}
|
|
|
|
@Override // com.google.android.gms.tasks.Task
|
|
public final Task<TResult> a(Executor executor, OnSuccessListener<? super TResult> onSuccessListener) {
|
|
this.b.a(new zzm(executor, onSuccessListener));
|
|
j();
|
|
return this;
|
|
}
|
|
|
|
@Override // com.google.android.gms.tasks.Task
|
|
public final Task<TResult> a(Executor executor, OnFailureListener onFailureListener) {
|
|
this.b.a(new zzk(executor, onFailureListener));
|
|
j();
|
|
return this;
|
|
}
|
|
|
|
@Override // com.google.android.gms.tasks.Task
|
|
public final Task<TResult> a(Executor executor, OnCompleteListener<TResult> onCompleteListener) {
|
|
this.b.a(new zzi(executor, onCompleteListener));
|
|
j();
|
|
return this;
|
|
}
|
|
|
|
@Override // com.google.android.gms.tasks.Task
|
|
public final <TContinuationResult> Task<TContinuationResult> a(Executor executor, Continuation<TResult, TContinuationResult> continuation) {
|
|
zzu zzuVar = new zzu();
|
|
this.b.a(new zzc(executor, continuation, zzuVar));
|
|
j();
|
|
return zzuVar;
|
|
}
|
|
|
|
public final boolean b(Exception exc) {
|
|
Preconditions.a(exc, "Exception must not be null");
|
|
synchronized (this.a) {
|
|
if (this.c) {
|
|
return false;
|
|
}
|
|
this.c = true;
|
|
this.f = exc;
|
|
this.b.a(this);
|
|
return true;
|
|
}
|
|
}
|
|
|
|
@Override // com.google.android.gms.tasks.Task
|
|
public final Task<TResult> a(Executor executor, OnCanceledListener onCanceledListener) {
|
|
this.b.a(new zzg(executor, onCanceledListener));
|
|
j();
|
|
return this;
|
|
}
|
|
|
|
public final void a(TResult tresult) {
|
|
synchronized (this.a) {
|
|
h();
|
|
this.c = true;
|
|
this.e = tresult;
|
|
}
|
|
this.b.a(this);
|
|
}
|
|
|
|
public final void a(Exception exc) {
|
|
Preconditions.a(exc, "Exception must not be null");
|
|
synchronized (this.a) {
|
|
h();
|
|
this.c = true;
|
|
this.f = exc;
|
|
}
|
|
this.b.a(this);
|
|
}
|
|
}
|