From f1ca83c59e681d862fc2dec72cb9d88a9a757583 Mon Sep 17 00:00:00 2001 From: M66B Date: Tue, 27 Dec 2022 23:15:25 +0100 Subject: [PATCH] Use dedicated contact info executors --- .../main/java/eu/faircode/email/ContactInfo.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/ContactInfo.java b/app/src/main/java/eu/faircode/email/ContactInfo.java index 06d06ebfc3..2796082a83 100644 --- a/app/src/main/java/eu/faircode/email/ContactInfo.java +++ b/app/src/main/java/eu/faircode/email/ContactInfo.java @@ -75,6 +75,7 @@ import java.util.Map; import java.util.concurrent.Callable; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ExecutionException; +import java.util.concurrent.ExecutorService; import java.util.concurrent.Future; import javax.mail.Address; @@ -99,6 +100,8 @@ public class ContactInfo { private static Map emailLookup = new ConcurrentHashMap<>(); private static final Map emailContactInfo = new HashMap<>(); + private static final ExecutorService executor = Helper.getBackgroundExecutor(0, "contact"); + private static final ExecutorService favicons = Helper.getBackgroundExecutor(0, "favicons"); private static final int GENERATED_ICON_SIZE = 48; // dp private static final int FAVICON_ICON_SIZE = 64; // dp @@ -374,7 +377,7 @@ public class ContactInfo { List> futures = new ArrayList<>(); if (bimi) - futures.add(Helper.getParallelExecutor().submit(new Callable() { + futures.add(executor.submit(new Callable() { @Override public Favicon call() throws Exception { Pair bimi = @@ -384,9 +387,9 @@ public class ContactInfo { })); if (gravatars) - futures.add(Helper.getParallelExecutor().submit(Avatar.getGravatar(email, scaleToPixels, context))); + futures.add(executor.submit(Avatar.getGravatar(email, scaleToPixels, context))); if (libravatars) - futures.add(Helper.getParallelExecutor().submit(Avatar.getLibravatar(email, scaleToPixels, context))); + futures.add(executor.submit(Avatar.getLibravatar(email, scaleToPixels, context))); if (favicons) { String host = domain; @@ -395,7 +398,7 @@ public class ContactInfo { while (host.indexOf('.') > 0) { final URL base = new URL("https://" + host); - futures.add(Helper.getParallelExecutor().submit(new Callable() { + futures.add(executor.submit(new Callable() { @Override public Favicon call() throws Exception { return parseFavicon(base, scaleToPixels, context); @@ -413,7 +416,7 @@ public class ContactInfo { final URL base = new URL("https://" + host); for (String name : FIXED_FAVICONS) - futures.add(Helper.getParallelExecutor().submit(new Callable() { + futures.add(executor.submit(new Callable() { @Override public Favicon call() throws Exception { return getFavicon(new URL(base, name), null, scaleToPixels, context); @@ -745,7 +748,7 @@ public class ContactInfo { continue; final URL url = new URL(base, favicon); - futures.add(Helper.getParallelExecutor().submit(new Callable>() { + futures.add(favicons.submit(new Callable>() { @Override public Pair call() throws Exception { return new Pair(getFavicon(url, img.attr("type"), scaleToPixels, context), url);