Files
rr3-apk/decompiled/sources/com/ironsource/environment/workerthread/WorkerManager.java
Daniel Elliott f9d20bb3fc Add decompiled APK source code (JADX)
- 28,932 files
- Full Java source code
- Smali files
- Resources

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-02-18 14:52:23 -08:00

80 lines
3.0 KiB
Java

package com.ironsource.environment.workerthread;
import com.ironsource.environment.workerthread.WorkerResult;
import com.ironsource.i9;
import com.ironsource.mediationsdk.logger.IronLog;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
/* loaded from: classes4.dex */
public class WorkerManager<T> {
List<Callable<T>> a = new ArrayList();
private final ExecutorService b;
public interface WorkEndedListener<T> {
void onWorkCompleted(List<WorkerResult<T>> list, long j);
void onWorkFailed(String str);
}
public WorkerManager(ExecutorService executorService) {
this.b = executorService;
}
public void addCallable(Callable<T> callable) {
this.a.add(callable);
}
public void startWork(WorkEndedListener<T> workEndedListener, long j, TimeUnit timeUnit) {
WorkerResult.Canceled canceled;
if (this.b.isShutdown()) {
workEndedListener.onWorkFailed("can not start work, executor has been shut down");
return;
}
if (this.a.isEmpty()) {
workEndedListener.onWorkFailed("can not start work, callable list is empty");
return;
}
long currentTimeMillis = System.currentTimeMillis();
ArrayList arrayList = new ArrayList();
try {
List<Future<T>> invokeAll = this.b.invokeAll(this.a, j, timeUnit);
for (int i = 0; i < invokeAll.size(); i++) {
Future<T> future = invokeAll.get(i);
if (!future.isDone() || future.isCancelled()) {
canceled = new WorkerResult.Canceled(this.a.get(i));
} else {
try {
arrayList.add(new WorkerResult.Completed(future.get()));
} catch (InterruptedException e) {
e = e;
i9.d().a(e);
arrayList.add(new WorkerResult.Failed(this.a.get(i), e));
} catch (CancellationException e2) {
i9.d().a(e2);
canceled = new WorkerResult.Canceled(this.a.get(i));
} catch (ExecutionException e3) {
e = e3;
i9.d().a(e);
arrayList.add(new WorkerResult.Failed(this.a.get(i), e));
}
}
arrayList.add(canceled);
}
workEndedListener.onWorkCompleted(arrayList, System.currentTimeMillis() - currentTimeMillis);
this.b.shutdownNow();
} catch (Exception e4) {
i9.d().a(e4);
IronLog.INTERNAL.error(e4.toString());
workEndedListener.onWorkFailed("failed to invoke callables, error= " + e4.getMessage());
this.b.shutdownNow();
}
}
}