Skip to content

Commit

Permalink
Retrigger
Browse files Browse the repository at this point in the history
  • Loading branch information
nomisRev committed Dec 4, 2022
1 parent 12a2ce7 commit 5cab776
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package arrow.fx.coroutines
import arrow.core.continuations.AtomicRef
import arrow.core.continuations.loop
import arrow.core.continuations.update
import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.CompletableDeferred

/**
Expand Down Expand Up @@ -41,8 +42,9 @@ public class CyclicBarrier @Throws(IllegalArgumentException::class) constructor(
} else if (state.compareAndSet(original, State(awaitingNow, epoch, unblock))) {
return try {
unblock.await()
} finally {
} catch (cancelled: CancellationException) {
state.update { s -> if (s.epoch == epoch) s.copy(awaiting = s.awaiting + 1) else s }
throw cancelled
}
}
}
Expand Down

0 comments on commit 5cab776

Please sign in to comment.