Skip to content

Commit

Permalink
Merge pull request #141 from cb372/fix-compile-error
Browse files Browse the repository at this point in the history
Fix compile error on Scala 2.11 (hangs head in shame)
  • Loading branch information
cb372 authored Dec 13, 2019
2 parents c6afb93 + a7daf9a commit 5e955f9
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions modules/core/jvm/src/main/scala/retry/Sleep.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import cats.{Eval, Id}

import scala.concurrent.duration.FiniteDuration
import scala.concurrent.{Future, Promise}
import java.util.concurrent.ThreadFactory

trait Sleep[M[_]] {
def sleep(delay: FiniteDuration): M[Unit]
Expand All @@ -23,13 +24,15 @@ object Sleep {
Eval.later(Thread.sleep(delay.toMillis))
}

private lazy val scheduler = Executors.newSingleThreadScheduledExecutor({
runnable =>
val t = new Thread(runnable)
t.setDaemon(true)
t.setName("cats-retry scheduler")
t
})
private lazy val scheduler =
Executors.newSingleThreadScheduledExecutor(new ThreadFactory {
override def newThread(runnable: Runnable) = {
val t = new Thread(runnable)
t.setDaemon(true)
t.setName("cats-retry scheduler")
t
}
})

implicit val threadSleepFuture: Sleep[Future] =
new Sleep[Future] {
Expand Down

0 comments on commit 5e955f9

Please sign in to comment.