Skip to content

Commit c4f2bbd

Browse files
committed
Simplify task counter incrementing
1 parent 34308ee commit c4f2bbd

File tree

1 file changed

+2
-8
lines changed
  • csharp/extractor/Semmle.Extraction.CSharp/Extractor

1 file changed

+2
-8
lines changed

csharp/extractor/Semmle.Extraction.CSharp/Extractor/Analyser.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Diagnostics;
44
using System.IO;
55
using System.Linq;
6+
using System.Threading;
67
using System.Threading.Tasks;
78
using Microsoft.CodeAnalysis;
89
using Microsoft.CodeAnalysis.CSharp;
@@ -23,8 +24,6 @@ public class Analyser : IDisposable
2324
private protected Entities.Compilation? compilationEntity;
2425
private IDisposable? compilationTrapFile;
2526

26-
private readonly object progressMutex = new object();
27-
2827
// The bulk of the extraction work, potentially executed in parallel.
2928
protected readonly List<Action> extractionTasks = new List<Action>();
3029
private int taskCount = 0;
@@ -242,8 +241,6 @@ private void DoAnalyseCompilation()
242241
try
243242
{
244243
var assemblyPath = extractor.OutputPath;
245-
246-
247244
var stopwatch = new Stopwatch();
248245
stopwatch.Start();
249246
var currentTaskId = IncrementTaskCount();
@@ -298,10 +295,7 @@ private static void AnalyseNamespace(Context cx, INamespaceSymbol ns)
298295

299296
private int IncrementTaskCount()
300297
{
301-
lock (progressMutex)
302-
{
303-
return ++taskCount;
304-
}
298+
return Interlocked.Increment(ref taskCount);
305299
}
306300

307301
private void ReportProgressTaskStarted(int currentCount, string src)

0 commit comments

Comments
 (0)