2021-11-02 06:38:17 +00:00
|
|
|
package z;
|
2021-08-03 07:33:18 +00:00
|
|
|
|
|
|
|
import bolts.ExecutorException;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.concurrent.Callable;
|
|
|
|
import java.util.concurrent.Executor;
|
|
|
|
import java.util.concurrent.ExecutorService;
|
2022-03-07 09:34:54 +00:00
|
|
|
/* compiled from: Task.java */
|
|
|
|
/* loaded from: classes.dex */
|
2021-08-03 07:33:18 +00:00
|
|
|
public class g<TResult> {
|
2022-01-13 08:07:50 +00:00
|
|
|
public static final ExecutorService a;
|
2021-08-03 07:33:18 +00:00
|
|
|
|
2021-12-17 21:59:34 +00:00
|
|
|
/* renamed from: b reason: collision with root package name */
|
2022-03-28 08:10:50 +00:00
|
|
|
public static final Executor f3853b;
|
2022-01-13 08:07:50 +00:00
|
|
|
public static final Executor c = a.a.e;
|
|
|
|
public static g<?> d = new g<>((Object) null);
|
|
|
|
public static g<Boolean> e = new g<>(Boolean.TRUE);
|
|
|
|
public static g<Boolean> f = new g<>(Boolean.FALSE);
|
|
|
|
public boolean h;
|
|
|
|
public boolean i;
|
|
|
|
public TResult j;
|
|
|
|
public Exception k;
|
|
|
|
public boolean l;
|
2022-03-07 09:34:54 +00:00
|
|
|
public final Object g = new Object();
|
2022-01-13 08:07:50 +00:00
|
|
|
public List<c<TResult, Void>> m = new ArrayList();
|
2021-08-03 07:33:18 +00:00
|
|
|
|
|
|
|
static {
|
|
|
|
b bVar = b.a;
|
2022-03-28 08:10:50 +00:00
|
|
|
a = bVar.f3851b;
|
|
|
|
f3853b = bVar.c;
|
2021-08-03 07:33:18 +00:00
|
|
|
new g(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
public g() {
|
|
|
|
}
|
|
|
|
|
|
|
|
public g(TResult tresult) {
|
|
|
|
h(tresult);
|
|
|
|
}
|
|
|
|
|
|
|
|
public g(boolean z2) {
|
|
|
|
if (z2) {
|
|
|
|
g();
|
|
|
|
} else {
|
|
|
|
h(null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static <TResult> g<TResult> a(Callable<TResult> callable, Executor executor) {
|
|
|
|
h hVar = new h();
|
|
|
|
try {
|
|
|
|
executor.execute(new f(hVar, callable));
|
2022-01-13 08:07:50 +00:00
|
|
|
} catch (Exception e2) {
|
|
|
|
hVar.b(new ExecutorException(e2));
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
|
|
|
return hVar.a;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static <TResult> g<TResult> c(Exception exc) {
|
|
|
|
boolean z2;
|
|
|
|
g<TResult> gVar = new g<>();
|
2022-01-13 08:07:50 +00:00
|
|
|
synchronized (gVar.g) {
|
2021-08-03 07:33:18 +00:00
|
|
|
z2 = false;
|
2022-01-13 08:07:50 +00:00
|
|
|
if (!gVar.h) {
|
|
|
|
gVar.h = true;
|
|
|
|
gVar.k = exc;
|
|
|
|
gVar.l = false;
|
|
|
|
gVar.g.notifyAll();
|
2021-08-03 07:33:18 +00:00
|
|
|
gVar.f();
|
|
|
|
z2 = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (z2) {
|
|
|
|
return gVar;
|
|
|
|
}
|
|
|
|
throw new IllegalStateException("Cannot set the error on a completed task.");
|
|
|
|
}
|
|
|
|
|
|
|
|
public <TContinuationResult> g<TContinuationResult> b(c<TResult, TContinuationResult> cVar) {
|
|
|
|
boolean z2;
|
2022-03-28 08:10:50 +00:00
|
|
|
Executor executor = f3853b;
|
2021-08-03 07:33:18 +00:00
|
|
|
h hVar = new h();
|
2022-01-13 08:07:50 +00:00
|
|
|
synchronized (this.g) {
|
|
|
|
synchronized (this.g) {
|
|
|
|
z2 = this.h;
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
|
|
|
if (!z2) {
|
2022-01-13 08:07:50 +00:00
|
|
|
this.m.add(new d(this, hVar, cVar, executor));
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (z2) {
|
|
|
|
try {
|
|
|
|
executor.execute(new e(hVar, cVar, this));
|
2022-01-13 08:07:50 +00:00
|
|
|
} catch (Exception e2) {
|
|
|
|
hVar.b(new ExecutorException(e2));
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return (g<TResult>) hVar.a;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Exception d() {
|
|
|
|
Exception exc;
|
2022-01-13 08:07:50 +00:00
|
|
|
synchronized (this.g) {
|
|
|
|
exc = this.k;
|
2021-08-03 07:33:18 +00:00
|
|
|
if (exc != null) {
|
2022-01-13 08:07:50 +00:00
|
|
|
this.l = true;
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return exc;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean e() {
|
|
|
|
boolean z2;
|
2022-01-13 08:07:50 +00:00
|
|
|
synchronized (this.g) {
|
2021-08-03 07:33:18 +00:00
|
|
|
z2 = d() != null;
|
|
|
|
}
|
|
|
|
return z2;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final void f() {
|
2022-01-13 08:07:50 +00:00
|
|
|
synchronized (this.g) {
|
|
|
|
for (c<TResult, Void> cVar : this.m) {
|
2021-08-03 07:33:18 +00:00
|
|
|
try {
|
|
|
|
cVar.a(this);
|
2022-01-13 08:07:50 +00:00
|
|
|
} catch (RuntimeException e2) {
|
|
|
|
throw e2;
|
|
|
|
} catch (Exception e3) {
|
|
|
|
throw new RuntimeException(e3);
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
|
|
|
}
|
2022-01-13 08:07:50 +00:00
|
|
|
this.m = null;
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean g() {
|
2022-01-13 08:07:50 +00:00
|
|
|
synchronized (this.g) {
|
|
|
|
if (this.h) {
|
2021-08-03 07:33:18 +00:00
|
|
|
return false;
|
|
|
|
}
|
2022-01-13 08:07:50 +00:00
|
|
|
this.h = true;
|
|
|
|
this.i = true;
|
|
|
|
this.g.notifyAll();
|
2021-08-03 07:33:18 +00:00
|
|
|
f();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean h(TResult tresult) {
|
2022-01-13 08:07:50 +00:00
|
|
|
synchronized (this.g) {
|
|
|
|
if (this.h) {
|
2021-08-03 07:33:18 +00:00
|
|
|
return false;
|
|
|
|
}
|
2022-01-13 08:07:50 +00:00
|
|
|
this.h = true;
|
|
|
|
this.j = tresult;
|
|
|
|
this.g.notifyAll();
|
2021-08-03 07:33:18 +00:00
|
|
|
f();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|