Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EMBCESSMOD-5523: calculate check compliance flags in parallel #2291

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
Expand Down Expand Up @@ -44,11 +45,11 @@ public SupportComplianceStrategy(params ISupportComplianceCheck[] strategies)

public async Task<CheckSupportComplianceResponse> CheckCompliance(CheckSupportComplianceRequest request, CancellationToken ct = default)
{
var flags = new Dictionary<Support, IEnumerable<SupportFlag>>();
foreach (var support in request.Supports)
var flags = new ConcurrentDictionary<Support, IEnumerable<SupportFlag>>();
await Parallel.ForEachAsync(request.Supports, ct, async (support, ct) =>
{
flags.Add(support, await CheckCompliance(support, ct));
}
flags.TryAdd(support, await CheckCompliance(support, ct));
});
return new CheckSupportComplianceResponse
{
Flags = flags
Expand Down