Skip to content

Commit 5600684

Browse files
committed
Incrementing BusyWait check interval and max wait defaults
1 parent 03d0d68 commit 5600684

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

Core/Cleipnir.ResilientFunctions/Helpers/BusyWait.cs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,18 @@ namespace Cleipnir.ResilientFunctions.Helpers;
77

88
public static class BusyWait
99
{
10+
private static readonly TimeSpan DefaultMaxWait = TimeSpan.FromSeconds(10);
11+
private static readonly TimeSpan DefaultCheckFrequency = TimeSpan.FromMicroseconds(5);
12+
1013
public static void Until(
1114
Func<bool> predicate,
1215
bool throwOnThresholdExceeded = true,
1316
TimeSpan? maxWait = null,
1417
TimeSpan? checkInterval = null
1518
)
1619
{
17-
checkInterval ??= TimeSpan.FromMilliseconds(1);
18-
maxWait ??= TimeSpan.FromSeconds(5);
20+
checkInterval ??= DefaultCheckFrequency;
21+
maxWait ??= DefaultMaxWait;
1922

2023
var stopWatch = new Stopwatch();
2124
stopWatch.Start();
@@ -46,8 +49,8 @@ public static async Task UntilAsync(
4649
TimeSpan? checkInterval = null
4750
)
4851
{
49-
checkInterval ??= TimeSpan.FromMilliseconds(1);
50-
maxWait ??= TimeSpan.FromSeconds(5);
52+
checkInterval ??= DefaultCheckFrequency;
53+
maxWait ??= DefaultMaxWait;
5154

5255
var stopWatch = new Stopwatch();
5356
stopWatch.Start();
@@ -71,8 +74,8 @@ public static async Task Until(
7174
TimeSpan? checkInterval = null
7275
)
7376
{
74-
checkInterval ??= TimeSpan.FromMilliseconds(1);
75-
maxWait ??= TimeSpan.FromSeconds(5);
77+
checkInterval ??= DefaultCheckFrequency;
78+
maxWait ??= DefaultMaxWait;
7679

7780
var stopWatch = new Stopwatch();
7881
stopWatch.Start();

0 commit comments

Comments
 (0)