Skip to content

Commit

Permalink
minor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
fwbrasil committed Oct 19, 2024
1 parent ac40e99 commit 29e9fa2
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions kyo-core/shared/src/main/scala/kyo/Meter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -333,11 +333,14 @@ object Meter:
// try to release a waiter
release()

@tailrec final private def pollWaiter(w: Promise.Unsafe[Closed, Unit] = waiters.poll()): Promise.Unsafe[Closed, Unit] =
if !isNull(w) then w
@tailrec final private def pollWaiter(): Promise.Unsafe[Closed, Unit] =
val waiter = waiters.poll()
if !isNull(waiter) then waiter
else
// If no waiter is found, retry the poll operation
// This handles the race condition between state change and waiter queuing
pollWaiter()
end if
end pollWaiter
end Base
end Meter

0 comments on commit 29e9fa2

Please sign in to comment.