package z; 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; /* compiled from: Task */ public class g { public static final Executor a; public static g b = new g<>((Object) null); /* renamed from: c reason: collision with root package name */ public static g f2937c = new g<>(Boolean.TRUE); public static g d = new g<>(Boolean.FALSE); public final Object e = new Object(); public boolean f; public boolean g; public TResult h; public Exception i; public boolean j; public List> k = new ArrayList(); static { b bVar = b.a; ExecutorService executorService = bVar.b; a = bVar.f2935c; Executor executor = a.a.e; new g(true); } public g() { } public g(TResult tresult) { h(tresult); } public g(boolean z2) { if (z2) { g(); } else { h(null); } } public static g a(Callable callable, Executor executor) { h hVar = new h(); try { executor.execute(new f(hVar, callable)); } catch (Exception e) { hVar.b(new ExecutorException(e)); } return hVar.a; } public static g c(Exception exc) { boolean z2; g gVar = new g<>(); synchronized (gVar.e) { z2 = false; if (!gVar.f) { gVar.f = true; gVar.i = exc; gVar.j = false; gVar.e.notifyAll(); gVar.f(); z2 = true; } } if (z2) { return gVar; } throw new IllegalStateException("Cannot set the error on a completed task."); } /* JADX DEBUG: Type inference failed for r7v3. Raw type applied. Possible types: z.g, z.g */ public g b(c cVar) { boolean z2; Executor executor = a; h hVar = new h(); synchronized (this.e) { synchronized (this.e) { z2 = this.f; } if (!z2) { this.k.add(new d(this, hVar, cVar, executor)); } } if (z2) { try { executor.execute(new e(hVar, cVar, this)); } catch (Exception e) { hVar.b(new ExecutorException(e)); } } return (g) hVar.a; } public Exception d() { Exception exc; synchronized (this.e) { exc = this.i; if (exc != null) { this.j = true; } } return exc; } public boolean e() { boolean z2; synchronized (this.e) { z2 = d() != null; } return z2; } public final void f() { synchronized (this.e) { for (c cVar : this.k) { try { cVar.a(this); } catch (RuntimeException e) { throw e; } catch (Exception e2) { throw new RuntimeException(e2); } } this.k = null; } } public boolean g() { synchronized (this.e) { if (this.f) { return false; } this.f = true; this.g = true; this.e.notifyAll(); f(); return true; } } public boolean h(TResult tresult) { synchronized (this.e) { if (this.f) { return false; } this.f = true; this.h = tresult; this.e.notifyAll(); f(); return true; } } }