Skip to content

Commit

Permalink
Merge pull request #419 from AVSystem/monix-bio-blocking
Browse files Browse the repository at this point in the history
Blocking Either as IO in BlockingUtils
  • Loading branch information
wodomierz authored Jun 28, 2022
2 parents 1b8683f + c2107ec commit 74ab6b9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.avsystem.commons.collection.CloseableIterator
import monix.eval.Task
import monix.execution.Scheduler
import monix.reactive.Observable
import monix.bio.IO

import scala.concurrent.Await
import scala.concurrent.duration._
Expand Down Expand Up @@ -38,6 +39,9 @@ abstract class BlockingUtils {
def asTask[T](blockingCode: => T): Task[T] =
Task.eval(blockingCode).executeOn(ioScheduler, forceAsync = true)

def asIO[A, B](blockingCode: => Either[A, B]): IO[A, B] =
IO.deferTotal(IO.fromEither(blockingCode)).executeOn(ioScheduler, forceAsync = true)

def await[T](future: Future[T]): T =
await(future, defaultTimeout)

Expand Down
2 changes: 2 additions & 0 deletions project/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ object Build extends BuildDef {
val scalaLoggingVersion = "3.9.4"
val akkaVersion = "2.6.14"
val monixVersion = "3.4.1"
val monixBioVersion = "1.2.0"
val mockitoVersion = "3.9.0"
val circeVersion = "0.13.0" // benchmark only
val upickleVersion = "1.3.11" // benchmark only
Expand Down Expand Up @@ -303,6 +304,7 @@ object Build extends BuildDef {
"com.google.code.findbugs" % "jsr305" % jsr305Version % Optional,
"com.google.guava" % "guava" % guavaVersion % Optional,
"io.monix" %% "monix" % monixVersion % Optional,
"io.monix" %% "monix-bio" % monixBioVersion % Optional,
),
)

Expand Down

0 comments on commit 74ab6b9

Please sign in to comment.