Closed SimonCropp closed 3 years ago
SemaphoreSlim allows async waiting. which doesnt block a thread
@toddams Is it causing any problems? It seems useful to me to be able to avoid blocking congestion? Granted, I don't have any uses with millions of requests a second that might be worth writing a benchmark test for.
@jzabroski i didnt do this for perf reasons. but to remove the .GetAwaiter().GetResult();
which is a common cause of deadlocks
@SimonCropp That is what I am referring to. My understanding is the deadlock only triggers when you exhaust all threads and the threads can't finish because the "buffer" in this case is the thread pool size. Am I wrong? Thank you.
Currently, our RaceCondition Tests in the build run in ~20 seconds but I think we only create 1,000 tasks, which would not stress the thread pool I believe. I wonder if the test (or another test) should call ThreadPool.GetMaxThreads and create a scenario where we test the number of concurrent tasks > max threads.
Thank you for your contribution. Can you please provide some explanations to your further MR, like why this change is introduced and what issue it resolves. I am also curious about this one, why SemaphoreSlim instead of lock?