From f04373e9492b76538069a20f74cea6914bb25d2c Mon Sep 17 00:00:00 2001 From: Juan Manuel Pereira Date: Thu, 14 Mar 2024 19:15:42 -0300 Subject: [PATCH] Add semaphore to run 10 scans at once --- .../DebugUI/DataBrokerRunCustomJSONViewModel.swift | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/DebugUI/DataBrokerRunCustomJSONViewModel.swift b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/DebugUI/DataBrokerRunCustomJSONViewModel.swift index 8a610f95a9..962211b42b 100644 --- a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/DebugUI/DataBrokerRunCustomJSONViewModel.swift +++ b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/DebugUI/DataBrokerRunCustomJSONViewModel.swift @@ -184,13 +184,18 @@ final class DataBrokerRunCustomJSONViewModel: ObservableObject { Task.detached { var scanResults = [DebugScanReturnValue]() + let semaphore = DispatchSemaphore(value: 10) try await withThrowingTaskGroup(of: DebugScanReturnValue.self) { group in for queryData in brokerProfileQueryData { + semaphore.wait() let debugScanOperation = DebugScanOperation(privacyConfig: self.privacyConfigManager, prefs: self.contentScopeProperties, query: queryData) { true } group.addTask { + defer { + semaphore.signal() + } do { return try await debugScanOperation.run(inputValue: (), stageCalculator: FakeStageDurationCalculator(), showWebView: false) } catch {