File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed
core/jvm/src/main/scala/cats/effect/unsafe Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -636,6 +636,7 @@ private[effect] final class WorkerThread[P <: AnyRef](
636636 acc
637637 }
638638
639+ @ tailrec
639640 def notifyDoneSleeping (): Unit = {
640641 val st = parked.get()
641642
@@ -645,9 +646,15 @@ private[effect] final class WorkerThread[P <: AnyRef](
645646 // this happens when we wake ourselves at the same moment the pool decides to wake us
646647
647648 while (parked.get() eq ParkedSignal .Interrupting ) {}
648- } else if (parked.compareAndSet(st, ParkedSignal .Unparked )) {
649- // we won the race to awaken ourselves, so we need to let the pool know
650- pool.doneSleeping()
649+ } else {
650+ if (parked.compareAndSet(st, ParkedSignal .Unparked )) {
651+ // we won the race to awaken ourselves, so we need to let the pool know
652+ pool.doneSleeping()
653+ } else {
654+ // lost CAS race, possibly concurrent `Interrupting`,
655+ // we'll need to re-read `parked`:
656+ notifyDoneSleeping()
657+ }
651658 }
652659 }
653660 }
You can’t perform that action at this time.
0 commit comments