import: reduce number of threads a little, and code cleanup
This commit is contained in:
@@ -82,6 +82,8 @@ import org.sufficientlysecure.keychain.util.orbot.OrbotHelper;
|
||||
*/
|
||||
public class ImportOperation extends BaseOperation<ImportKeyringParcel> {
|
||||
|
||||
public static final int MAX_THREADS = 10;
|
||||
|
||||
public ImportOperation(Context context, ProviderHelper providerHelper, Progressable
|
||||
progressable) {
|
||||
super(context, providerHelper, progressable);
|
||||
@@ -412,18 +414,15 @@ public class ImportOperation extends BaseOperation<ImportKeyringParcel> {
|
||||
}
|
||||
|
||||
@NonNull
|
||||
private ImportKeyResult multiThreadedKeyImport(Iterator<ParcelableKeyRing> keyListIterator,
|
||||
private ImportKeyResult multiThreadedKeyImport(@NonNull Iterator<ParcelableKeyRing> keyListIterator,
|
||||
int totKeys, final String keyServer,
|
||||
final Proxy proxy) {
|
||||
Log.d(Constants.TAG, "Multi-threaded key import starting");
|
||||
if (keyListIterator != null) {
|
||||
KeyImportAccumulator accumulator = new KeyImportAccumulator(totKeys, mProgressable);
|
||||
|
||||
final ProgressScaler ignoreProgressable = new ProgressScaler();
|
||||
|
||||
final int maxThreads = 200;
|
||||
ExecutorService importExecutor = new ThreadPoolExecutor(0, maxThreads,
|
||||
30L, TimeUnit.SECONDS,
|
||||
ExecutorService importExecutor = new ThreadPoolExecutor(0, MAX_THREADS, 30L, TimeUnit.SECONDS,
|
||||
new SynchronousQueue<Runnable>());
|
||||
|
||||
ExecutorCompletionService<ImportKeyResult> importCompletionService =
|
||||
@@ -465,8 +464,7 @@ public class ImportOperation extends BaseOperation<ImportKeyringParcel> {
|
||||
}
|
||||
}
|
||||
return accumulator.getConsolidatedResult();
|
||||
}
|
||||
return new ImportKeyResult(ImportKeyResult.RESULT_FAIL_NOTHING, new OperationLog());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -500,7 +498,7 @@ public class ImportOperation extends BaseOperation<ImportKeyringParcel> {
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void accumulateKeyImport(ImportKeyResult result) {
|
||||
public void accumulateKeyImport(ImportKeyResult result) {
|
||||
mImportedKeys++;
|
||||
|
||||
if (mProgressable != null) {
|
||||
|
||||
Reference in New Issue
Block a user