Skip to content

Commit

Permalink
Merge pull request #4214 from djspiewak/bug/broken-arm-block-detection
Browse files Browse the repository at this point in the history
Fixed off-by-one error in other index selection
  • Loading branch information
armanbilge authored Dec 27, 2024
2 parents 5e470b1 + bf77077 commit ead4b58
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ private[effect] final class WorkerThread[P <: AnyRef](
// TODO check that branch elimination makes it free when off
val idx = index
val threadCount = pool.getWorkerThreadCount()
val otherIdx = (idx + random.nextInt(threadCount - 1)) % threadCount
val otherIdx = (idx + random.nextInt(threadCount - 1) + 1) % threadCount
val thread = pool.getWorkerThread(otherIdx)
val state = thread.getState()
val parked = thread.parked
Expand Down
4 changes: 2 additions & 2 deletions tests/jvm/src/main/scala/catseffect/examplesplatform.scala
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ package examples {
override protected def blockedThreadDetectionEnabled = true

// Loop prevents other worker threads from being parked and hence not
// performing the blocked check
// performing the blocked check. Cedeing makes the test more deterministic
val run =
IO.unit.foreverM.start >> IO(Thread.sleep(2.seconds.toMillis))
IO.cede.foreverM.start >> IO(Thread.sleep(2.seconds.toMillis))
}
}

0 comments on commit ead4b58

Please sign in to comment.