You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Test]publicasyncTaskTestCancellationDoesNotLeadToLostSignal([Values]boolasync){varsemaphore=newWaitHandleDistributedSemaphore(nameof(this.TestCancellationDoesNotLeadToLostSignal),2);awaitusingvar_=awaitsemaphore.AcquireAsync(TimeSpan.FromSeconds(1));for(vari=0;i<50;++i){usingvarbarrier=newBarrier(2);usingvarsource=newCancellationTokenSource();varacquireTask=Task.Run(async()=>{barrier.SignalAndWait();try{if(async){awaitusing var _ =awaitsemaphore.AcquireAsync(cancellationToken:source.Token);}else{usingvar_=semaphore.Acquire(cancellationToken:source.Token);}}catchwhen(source.Token.IsCancellationRequested){}});varcancelTask=Task.Run(()=>{barrier.SignalAndWait();source.Cancel();});awaitTask.WhenAll(acquireTask,cancelTask);}awaitusingvarhandle=awaitsemaphore.TryAcquireAsync();Assert.IsNotNull(handle);// if we lost even a single signal due to cancellation in the loop above, this will fail}
Referring to https://github.com/madelson/DistributedLock/blob/master/DistributedLock.WaitHandles/WaitHandleExtensions.cs#L43
Consider the following case:
In that case, I think we lose a signal on the handle; ideally if the wait callback fails to set the task then it should re-signal the event.
The text was updated successfully, but these errors were encountered: