Skip to content

Commit

Permalink
Neaten bulkhead tests commentary
Browse files Browse the repository at this point in the history
  • Loading branch information
reisenberger authored and YarekTyshchenko committed Oct 15, 2021
1 parent e55c059 commit 88d6038
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Polly.Specs/Helpers/Bulkhead/TraceableAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ public void SignalStateChange()
_statusChanged.Set();
}

// Note re TaskCreationOptions.LongRunning: Testing the parallelization of the bulkhead policy efficiently requires the ability to start large numbers of parallel tasks in a short space of time.
// The ThreadPool's algorithm of only injecting extra threads (when necessary) at a rate of two-per-second however makes high-volume tests using the ThreadPool both slow and flaky. In the days of PCL, further, ThreadPool.SetMinThreads(...) was not available to mitigate this.
// Using TaskCreationOptions.LongRunning allows us to force tasks to be started near-instantly on non-ThreadPool threads.
// Similarly, we use ConfigureAwait(true) when awaiting, to avoid continuations being scheduled onto a ThreadPool thread, which may only be injected too slowly in high-volume tests.

public Task ExecuteOnBulkhead(BulkheadPolicy bulkhead)
{
return ExecuteThroughSyncBulkheadOuter(
Expand Down

0 comments on commit 88d6038

Please sign in to comment.