Skip to content

Commit

Permalink
Merge pull request #453 from JetBrains/ww898-fix-SpinUntil
Browse files Browse the repository at this point in the history
Grant the condition call if `SpinUntil()` has zero timeout.
  • Loading branch information
Iliya-usov authored Dec 12, 2023
2 parents 1823afd + 186a35f commit 3667470
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 3667470

Please sign in to comment.