mirror of
https://github.com/VibedByKaKi/alexandroid.git
synced 2026-11-13 01:17:17 +01:00
61 lines
2 KiB
Java
61 lines
2 KiB
Java
package dagger.internal;
|
|
|
|
import dagger.Lazy;
|
|
import io.ktor.http.CodecsKt$$ExternalSyntheticBUOutline0;
|
|
import javax.inject.Provider;
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
/* loaded from: classes9.dex */
|
|
public final class DoubleCheck<T> implements Provider<T>, Lazy<T> {
|
|
static final /* synthetic */ boolean $assertionsDisabled = false;
|
|
private static final Object UNINITIALIZED = new Object();
|
|
private volatile Object instance = UNINITIALIZED;
|
|
private volatile Provider<T> provider;
|
|
|
|
private DoubleCheck(Provider<T> provider) {
|
|
this.provider = provider;
|
|
}
|
|
|
|
public static <P extends Provider<T>, T> Lazy<T> lazy(P p) {
|
|
return p instanceof Lazy ? (Lazy) p : new DoubleCheck((Provider) Preconditions.checkNotNull(p));
|
|
}
|
|
|
|
public static <P extends Provider<T>, T> Provider<T> provider(P p) {
|
|
Preconditions.checkNotNull(p);
|
|
return p instanceof DoubleCheck ? p : new DoubleCheck(p);
|
|
}
|
|
|
|
private static Object reentrantCheck(Object obj, Object obj2) {
|
|
if (obj == UNINITIALIZED) {
|
|
return obj2;
|
|
}
|
|
if (obj == obj2) {
|
|
return obj2;
|
|
}
|
|
CodecsKt$$ExternalSyntheticBUOutline0.m("Scoped provider was invoked recursively returning different results: ", obj, " & ", obj2, ". This is likely due to a circular dependency.");
|
|
return null;
|
|
}
|
|
|
|
@Override // javax.inject.Provider
|
|
public T get() {
|
|
T t;
|
|
T t2 = (T) this.instance;
|
|
Object obj = UNINITIALIZED;
|
|
if (t2 != obj) {
|
|
return t2;
|
|
}
|
|
synchronized (this) {
|
|
try {
|
|
t = (T) this.instance;
|
|
if (t == obj) {
|
|
t = this.provider.get();
|
|
this.instance = reentrantCheck(this.instance, t);
|
|
this.provider = null;
|
|
}
|
|
} catch (Throwable th) {
|
|
throw th;
|
|
}
|
|
}
|
|
return t;
|
|
}
|
|
}
|