Skip to content

Commit

Permalink
Grant the condition call if SpinUntil() has zero timeout.
Browse files Browse the repository at this point in the history
  • Loading branch information
ww898 committed Dec 6, 2023
1 parent 1823afd commit 186a35f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion rd-net/Lifetimes/Threading/SpinWaitEx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,15 @@ public static bool SpinUntil(Lifetime lifetime, long timeoutMs, Func<bool> condi

while (true)
{
if (!lifetime.IsAlive || Environment.TickCount - start > timeoutMs)
if (!lifetime.IsAlive)
return false;

if (condition())
return true;

if (Environment.TickCount - start > timeoutMs)
return false;

#if !NET35
s.SpinOnce();
#else
Expand Down

0 comments on commit 186a35f

Please sign in to comment.