98 lines
3.4 KiB
Java
98 lines
3.4 KiB
Java
package com.google.common.util.concurrent;
|
|
|
|
import com.google.common.base.Preconditions;
|
|
import com.google.common.util.concurrent.AbstractFuture;
|
|
import java.util.concurrent.ExecutionException;
|
|
import java.util.concurrent.Executor;
|
|
import java.util.concurrent.TimeUnit;
|
|
import java.util.logging.Level;
|
|
import java.util.logging.Logger;
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* loaded from: classes2.dex */
|
|
public class ImmediateFuture<V> implements ListenableFuture<V> {
|
|
static final ListenableFuture<?> NULL = new ImmediateFuture(null);
|
|
private static final Logger log = Logger.getLogger(ImmediateFuture.class.getName());
|
|
private final V value;
|
|
|
|
@Override // java.util.concurrent.Future
|
|
public boolean cancel(boolean z) {
|
|
return false;
|
|
}
|
|
|
|
@Override // java.util.concurrent.Future
|
|
public boolean isCancelled() {
|
|
return false;
|
|
}
|
|
|
|
@Override // java.util.concurrent.Future
|
|
public boolean isDone() {
|
|
return true;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public ImmediateFuture(V v) {
|
|
this.value = v;
|
|
}
|
|
|
|
@Override // com.google.common.util.concurrent.ListenableFuture
|
|
public void addListener(Runnable runnable, Executor executor) {
|
|
Preconditions.checkNotNull(runnable, "Runnable was null.");
|
|
Preconditions.checkNotNull(executor, "Executor was null.");
|
|
try {
|
|
executor.execute(runnable);
|
|
} catch (RuntimeException e) {
|
|
Logger logger = log;
|
|
Level level = Level.SEVERE;
|
|
String valueOf = String.valueOf(runnable);
|
|
String valueOf2 = String.valueOf(executor);
|
|
StringBuilder sb = new StringBuilder(String.valueOf(valueOf).length() + 57 + String.valueOf(valueOf2).length());
|
|
sb.append("RuntimeException while executing runnable ");
|
|
sb.append(valueOf);
|
|
sb.append(" with executor ");
|
|
sb.append(valueOf2);
|
|
logger.log(level, sb.toString(), (Throwable) e);
|
|
}
|
|
}
|
|
|
|
@Override // java.util.concurrent.Future
|
|
public V get(long j, TimeUnit timeUnit) throws ExecutionException {
|
|
Preconditions.checkNotNull(timeUnit);
|
|
return get();
|
|
}
|
|
|
|
public String toString() {
|
|
String obj = super.toString();
|
|
String valueOf = String.valueOf(this.value);
|
|
StringBuilder sb = new StringBuilder(String.valueOf(obj).length() + 27 + String.valueOf(valueOf).length());
|
|
sb.append(obj);
|
|
sb.append("[status=SUCCESS, result=[");
|
|
sb.append(valueOf);
|
|
sb.append("]]");
|
|
return sb.toString();
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* loaded from: classes2.dex */
|
|
public static final class ImmediateFailedFuture<V> extends AbstractFuture.TrustedFuture<V> {
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public ImmediateFailedFuture(Throwable th) {
|
|
setException(th);
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* loaded from: classes2.dex */
|
|
public static final class ImmediateCancelledFuture<V> extends AbstractFuture.TrustedFuture<V> {
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public ImmediateCancelledFuture() {
|
|
cancel(false);
|
|
}
|
|
}
|
|
|
|
@Override // java.util.concurrent.Future
|
|
public V get() {
|
|
return this.value;
|
|
}
|
|
}
|