package com.google.common.util.concurrent; import com.google.common.base.Preconditions; import com.google.common.base.Throwables; import com.google.common.collect.ImmutableList; import java.util.Collection; import java.util.Iterator; import java.util.List; import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; /* loaded from: classes2.dex */ abstract class WrappingExecutorService implements ExecutorService { private final ExecutorService delegate; /* JADX INFO: Access modifiers changed from: protected */ public abstract Callable wrapTask(Callable callable); /* JADX INFO: Access modifiers changed from: protected */ public WrappingExecutorService(ExecutorService executorService) { this.delegate = (ExecutorService) Preconditions.checkNotNull(executorService); } /* JADX INFO: Access modifiers changed from: protected */ public Runnable wrapTask(Runnable runnable) { return new Runnable(this, wrapTask(Executors.callable(runnable, null))) { // from class: com.google.common.util.concurrent.WrappingExecutorService.1 final Callable val$wrapped; { this.val$wrapped = r2; } @Override // java.lang.Runnable public void run() { try { this.val$wrapped.call(); } catch (Exception e) { Throwables.throwIfUnchecked(e); throw new RuntimeException(e); } } }; } private ImmutableList> wrapTasks(Collection> collection) { ImmutableList.Builder builder = ImmutableList.builder(); Iterator> it = collection.iterator(); while (it.hasNext()) { builder.add((ImmutableList.Builder) wrapTask(it.next())); } return builder.build(); } @Override // java.util.concurrent.Executor public final void execute(Runnable runnable) { this.delegate.execute(wrapTask(runnable)); } @Override // java.util.concurrent.ExecutorService public final Future submit(Callable callable) { return this.delegate.submit(wrapTask((Callable) Preconditions.checkNotNull(callable))); } @Override // java.util.concurrent.ExecutorService public final Future submit(Runnable runnable) { return this.delegate.submit(wrapTask(runnable)); } @Override // java.util.concurrent.ExecutorService public final Future submit(Runnable runnable, T t) { return this.delegate.submit(wrapTask(runnable), t); } @Override // java.util.concurrent.ExecutorService public final List> invokeAll(Collection> collection) throws InterruptedException { return this.delegate.invokeAll(wrapTasks(collection)); } @Override // java.util.concurrent.ExecutorService public final List> invokeAll(Collection> collection, long j, TimeUnit timeUnit) throws InterruptedException { return this.delegate.invokeAll(wrapTasks(collection), j, timeUnit); } @Override // java.util.concurrent.ExecutorService public final T invokeAny(Collection> collection) throws InterruptedException, ExecutionException { return (T) this.delegate.invokeAny(wrapTasks(collection)); } @Override // java.util.concurrent.ExecutorService public final T invokeAny(Collection> collection, long j, TimeUnit timeUnit) throws InterruptedException, ExecutionException, TimeoutException { return (T) this.delegate.invokeAny(wrapTasks(collection), j, timeUnit); } @Override // java.util.concurrent.ExecutorService public final void shutdown() { this.delegate.shutdown(); } @Override // java.util.concurrent.ExecutorService public final List shutdownNow() { return this.delegate.shutdownNow(); } @Override // java.util.concurrent.ExecutorService public final boolean isShutdown() { return this.delegate.isShutdown(); } @Override // java.util.concurrent.ExecutorService public final boolean isTerminated() { return this.delegate.isTerminated(); } @Override // java.util.concurrent.ExecutorService public final boolean awaitTermination(long j, TimeUnit timeUnit) throws InterruptedException { return this.delegate.awaitTermination(j, timeUnit); } }