From 1f73b9052509bb3f4e094d3587830b6f32ad956d Mon Sep 17 00:00:00 2001 From: zarazaex69 Date: Sat, 4 Apr 2026 19:02:49 +0300 Subject: [PATCH] perf(RealPingWorkerService): increase thread pool size and add exception handling --- .../main/java/com/v2ray/ang/service/RealPingWorkerService.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/V2rayNG/app/src/main/java/com/v2ray/ang/service/RealPingWorkerService.kt b/V2rayNG/app/src/main/java/com/v2ray/ang/service/RealPingWorkerService.kt index 5617f5de..5dfefd10 100644 --- a/V2rayNG/app/src/main/java/com/v2ray/ang/service/RealPingWorkerService.kt +++ b/V2rayNG/app/src/main/java/com/v2ray/ang/service/RealPingWorkerService.kt @@ -27,7 +27,7 @@ class RealPingWorkerService( ) { private val job = SupervisorJob() private val cpu = Runtime.getRuntime().availableProcessors().coerceAtLeast(1) - private val dispatcher = Executors.newFixedThreadPool(cpu * 4).asCoroutineDispatcher() + private val dispatcher = Executors.newFixedThreadPool(cpu * 16).asCoroutineDispatcher() private val scope = CoroutineScope(job + dispatcher + CoroutineName("RealPingBatchWorker")) private val runningCount = AtomicInteger(0) @@ -41,6 +41,8 @@ class RealPingWorkerService( try { val result = startRealPing(guid) MessageUtil.sendMsg2UI(context, AppConfig.MSG_MEASURE_CONFIG_SUCCESS, Pair(guid, result)) + } catch (e: Exception) { + MessageUtil.sendMsg2UI(context, AppConfig.MSG_MEASURE_CONFIG_SUCCESS, Pair(guid, -1L)) } finally { val count = totalCount.decrementAndGet() val left = runningCount.decrementAndGet()