Browse Source

Add comments in CqlStorage

Olivier Coanet 3 years ago
parent
commit
09fe755b33
1 changed files with 5 additions and 0 deletions
  1. 5 0
      src/Abc.Zebus.Persistence.Cassandra/Cql/CqlStorage.cs

+ 5 - 0
src/Abc.Zebus.Persistence.Cassandra/Cql/CqlStorage.cs

@@ -86,7 +86,12 @@ namespace Abc.Zebus.Persistence.Cassandra.Cql
             }
 
             var insertTasks = new List<Task>();
+
+            // The SemaphoreSlim is deliberately not disposed here:
+            // - Disposing the semaphore is only useful to dispose the underlying WaitHandle, which is not used (instantiated) here.
+            // - Disposing the semaphore would require complex logic: it must be disposed after the insertTask continuations to avoid ObjectDisposedException.
             var remaining = new SemaphoreSlim(_maxParallelInsertTasks);
+
             foreach (var matcherEntry in entriesToPersist)
             {
                 var gotSlot = remaining.Wait(TimeSpan.FromSeconds(10));