ValueTaskAwaiter<FlushResult> awaiter = buffer.FlushAsync(cts.Token).GetAwaiter();
awaiter.OnCompleted(
() => {
- // We are on cancellation thread and need to wait untill another FlushAsync call
+ // We are on cancellation thread and need to wait until another FlushAsync call
// takes pipe state lock
e.Wait();
buffer.FlushAsync();
});
- // Start a thread that would run cancellation calbacks
+ // Start a thread that would run cancellation callbacks
Task cancellationTask = Task.Run(() => cts.Cancel());
// Start a thread that would call FlushAsync with different token
// and block on _cancellationTokenRegistration.Dispose
buffer.FlushAsync(cts2.Token);
});
- bool completed = Task.WhenAll(cancellationTask, blockingTask).Wait(TimeSpan.FromSeconds(10));
- Assert.True(completed);
+ bool completed = Task.WhenAll(cancellationTask, blockingTask).Wait(TimeSpan.FromSeconds(30));
+ Assert.True(completed, $"Flush tasks are not completed. CancellationTask: {cancellationTask.Status} BlockingTask: {blockingTask.Status}");
}
[Fact]
}
[Fact]
- public void FlushAsyncCancellationDeadlock()
+ public void ReadAsyncCancellationDeadlock()
{
var cts = new CancellationTokenSource();
var cts2 = new CancellationTokenSource();
ValueTaskAwaiter<ReadResult> awaiter = Pipe.Reader.ReadAsync(cts.Token).GetAwaiter();
awaiter.OnCompleted(
() => {
- // We are on cancellation thread and need to wait untill another ReadAsync call
+ // We are on cancellation thread and need to wait until another ReadAsync call
// takes pipe state lock
e.Wait();
// Make sure we had enough time to reach _cancellationTokenRegistration.Dispose
Pipe.Reader.ReadAsync();
});
- // Start a thread that would run cancellation calbacks
+ // Start a thread that would run cancellation callbacks
Task cancellationTask = Task.Run(() => cts.Cancel());
// Start a thread that would call ReadAsync with different token
// and block on _cancellationTokenRegistration.Dispose
Pipe.Reader.ReadAsync(cts2.Token);
});
- bool completed = Task.WhenAll(cancellationTask, blockingTask).Wait(TimeSpan.FromSeconds(10));
- Assert.True(completed);
+ bool completed = Task.WhenAll(cancellationTask, blockingTask).Wait(TimeSpan.FromSeconds(30));
+ Assert.True(completed, $"Read tasks are not completed. CancellationTask: {cancellationTask.Status} BlockingTask: {blockingTask.Status}");
}
[Fact]