Skip to content

Commit

Permalink
scalafmt
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristopherDavenport committed Sep 14, 2021
1 parent a377c0d commit 79c7ae8
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions std/shared/src/main/scala/cats/effect/std/Semaphore.scala
Original file line number Diff line number Diff line change
Expand Up @@ -220,14 +220,17 @@ object Semaphore {

if (n == 0) F.unit
else
state.modify {
case State(permits, waiting) =>
if (waiting.isEmpty) State(permits + n, waiting) -> F.unit
else {
val (newN, waitingNow, wakeup) = fulfil(n, waiting, Q())
State(newN, waitingNow) -> wakeup.traverse_(_.complete)
}
}.flatten.uncancelable
state
.modify {
case State(permits, waiting) =>
if (waiting.isEmpty) State(permits + n, waiting) -> F.unit
else {
val (newN, waitingNow, wakeup) = fulfil(n, waiting, Q())
State(newN, waitingNow) -> wakeup.traverse_(_.complete)
}
}
.flatten
.uncancelable
}

def available: F[Long] = state.get.map(_.permits)
Expand Down

0 comments on commit 79c7ae8

Please sign in to comment.