Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions core/jvm/src/main/scala/scalaz/zio/blocking/Blocking.scala
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,22 @@ object Blocking extends Serializable {
} finally lock.unlock()

val interruptThread: UIO[Unit] =
ZIO.effectTotal(withMutex(thread.get match {
case None => ()
case Some(thread) => thread.interrupt()
}))
ZIO.effectTotal {
var looping = true
var n = 0L
val base = 2L
while (looping) {
withMutex(thread.get match {
case None => looping = false; ()
case Some(thread) => thread.interrupt()
})

if (looping) {
n += 1
Thread.sleep(math.min(50, base * n))
}
}
}

val awaitInterruption: UIO[Unit] = ZIO.effectTotal(barrier.get())

Expand Down