package wow.doge.mygame.executors

import com.typesafe.scalalogging.Logger
import monix.execution.Scheduler
import monix.execution.UncaughtExceptionReporter

final case class Schedulers(
    blockingIO: Scheduler = Scheduler
      .io()
      .withUncaughtExceptionReporter(Schedulers.reporter),
    async: Scheduler = Scheduler.global
      .withUncaughtExceptionReporter(Schedulers.reporter),
    fx: Scheduler = JFXExecutionContexts.fxScheduler
      .withUncaughtExceptionReporter(Schedulers.reporter)
)

object Schedulers {
  val reporter = UncaughtExceptionReporter { ex =>
    val logger = Logger[Schedulers]
    logger.error("Uncaught exception", ex)
  }

}
