Unified executor model

This commit is contained in:
M66B
2022-12-13 10:52:39 +01:00
parent 101371854b
commit 6988d4c552
33 changed files with 147 additions and 297 deletions

View File

@@ -81,11 +81,6 @@ import java.util.WeakHashMap;
import java.util.concurrent.ExecutorService;
class ImageHelper {
private static final ExecutorService executor_1 =
Helper.getBackgroundExecutor(1, "image_1");
private static final ExecutorService executor_n =
Helper.getBackgroundExecutor(0, "image_n");
static final int DOWNLOAD_TIMEOUT = 15; // seconds
private static final int MAX_PROBE = 128 * 1024; // bytes
private static final int SLOW_CONNECTION = 2 * 1024; // Kbps
@@ -475,7 +470,9 @@ class ImageHelper {
lld.setLevel(1);
Integer kbps = ConnectionHelper.getLinkDownstreamBandwidthKbps(context);
ExecutorService executor = (kbps != null && kbps < SLOW_CONNECTION ? executor_1 : executor_n);
ExecutorService executor = (kbps != null && kbps < SLOW_CONNECTION
? Helper.getSerialExecutor()
: Helper.getParallelExecutor());
executor.submit(new Runnable() {
@Override