mirror of
https://github.com/Pinball3D/Rabbit-R1.git
synced 2025-01-09 13:43:22 +00:00
100 lines
3.9 KiB
Java
100 lines
3.9 KiB
Java
package com.google.common.util.concurrent;
|
|
|
|
import com.google.common.base.Preconditions;
|
|
import com.google.common.base.Supplier;
|
|
import java.util.concurrent.Callable;
|
|
|
|
@ElementTypesAreNonnullByDefault
|
|
/* loaded from: classes3.dex */
|
|
public final class Callables {
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public static /* synthetic */ Object lambda$returning$0(Object obj) throws Exception {
|
|
return obj;
|
|
}
|
|
|
|
private Callables() {
|
|
}
|
|
|
|
public static <T> Callable<T> returning(@ParametricNullness final T t) {
|
|
return new Callable() { // from class: com.google.common.util.concurrent.Callables$$ExternalSyntheticLambda0
|
|
@Override // java.util.concurrent.Callable
|
|
public final Object call() {
|
|
return Callables.lambda$returning$0(t);
|
|
}
|
|
};
|
|
}
|
|
|
|
public static <T> AsyncCallable<T> asAsyncCallable(final Callable<T> callable, final ListeningExecutorService listeningExecutorService) {
|
|
Preconditions.checkNotNull(callable);
|
|
Preconditions.checkNotNull(listeningExecutorService);
|
|
return new AsyncCallable() { // from class: com.google.common.util.concurrent.Callables$$ExternalSyntheticLambda3
|
|
@Override // com.google.common.util.concurrent.AsyncCallable
|
|
public final ListenableFuture call() {
|
|
ListenableFuture submit;
|
|
submit = ListeningExecutorService.this.submit(callable);
|
|
return submit;
|
|
}
|
|
};
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public static <T> Callable<T> threadRenaming(final Callable<T> callable, final Supplier<String> supplier) {
|
|
Preconditions.checkNotNull(supplier);
|
|
Preconditions.checkNotNull(callable);
|
|
return new Callable() { // from class: com.google.common.util.concurrent.Callables$$ExternalSyntheticLambda2
|
|
@Override // java.util.concurrent.Callable
|
|
public final Object call() {
|
|
return Callables.lambda$threadRenaming$2(Supplier.this, callable);
|
|
}
|
|
};
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public static /* synthetic */ Object lambda$threadRenaming$2(Supplier supplier, Callable callable) throws Exception {
|
|
Thread currentThread = Thread.currentThread();
|
|
String name = currentThread.getName();
|
|
boolean trySetName = trySetName((String) supplier.get(), currentThread);
|
|
try {
|
|
return callable.call();
|
|
} finally {
|
|
if (trySetName) {
|
|
trySetName(name, currentThread);
|
|
}
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public static Runnable threadRenaming(final Runnable runnable, final Supplier<String> supplier) {
|
|
Preconditions.checkNotNull(supplier);
|
|
Preconditions.checkNotNull(runnable);
|
|
return new Runnable() { // from class: com.google.common.util.concurrent.Callables$$ExternalSyntheticLambda1
|
|
@Override // java.lang.Runnable
|
|
public final void run() {
|
|
Callables.lambda$threadRenaming$3(Supplier.this, runnable);
|
|
}
|
|
};
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public static /* synthetic */ void lambda$threadRenaming$3(Supplier supplier, Runnable runnable) {
|
|
Thread currentThread = Thread.currentThread();
|
|
String name = currentThread.getName();
|
|
boolean trySetName = trySetName((String) supplier.get(), currentThread);
|
|
try {
|
|
runnable.run();
|
|
} finally {
|
|
if (trySetName) {
|
|
trySetName(name, currentThread);
|
|
}
|
|
}
|
|
}
|
|
|
|
private static boolean trySetName(String str, Thread thread) {
|
|
try {
|
|
thread.setName(str);
|
|
return true;
|
|
} catch (SecurityException unused) {
|
|
return false;
|
|
}
|
|
}
|
|
}
|