diff --git a/src/Stryker.Core/Stryker.Core/Initialisation/InputFileResolver.cs b/src/Stryker.Core/Stryker.Core/Initialisation/InputFileResolver.cs index f2b249c7a..9410a2e22 100644 --- a/src/Stryker.Core/Stryker.Core/Initialisation/InputFileResolver.cs +++ b/src/Stryker.Core/Stryker.Core/Initialisation/InputFileResolver.cs @@ -542,20 +542,20 @@ private static StringBuilder BuildReferenceChoice(IEnumerable projectRef private sealed class DynamicEnumerableQueue { - private readonly Queue _queue; - private readonly HashSet _cache; + private readonly ConcurrentQueue _queue; + private readonly ConcurrentDictionary _cache; public DynamicEnumerableQueue(IEnumerable init) { - _cache = [.. init]; - _queue = new Queue(_cache); + _cache = new(init.ToDictionary(x => x, x => true)); + _queue = new (_cache.Keys); } - public bool Empty => _queue.Count == 0; + public bool Empty => _queue.IsEmpty; public void Add(T entry) { - if (!_cache.Add(entry)) + if (!_cache.TryAdd(entry, true)) { return; } @@ -566,7 +566,10 @@ public IEnumerable Consume() { while (_queue.Count > 0) { - yield return _queue.Dequeue(); + if (_queue.TryDequeue(out var entry)) + { + yield return entry; + } } } }