All Downloads are FREE. Search and download functionalities are using the official Maven repository.

zio.ZIOPlatformSpecificJVM.scala Maven / Gradle / Ivy

There is a newer version: 2.1.11
Show newest version
package zio

import zio.interop.javaz

import java.nio.channels.CompletionHandler
import java.util.concurrent.{CompletableFuture, CompletionStage, Future}

private[zio] trait ZIOPlatformSpecificJVM {

  def asyncWithCompletionHandler[T](op: CompletionHandler[T, Any] => Any)(implicit trace: Trace): Task[T] =
    javaz.asyncWithCompletionHandler(op)

  def fromCompletionStage[A](cs: => CompletionStage[A])(implicit trace: Trace): Task[A] =
    javaz.fromCompletionStage(cs)

  /**
   * Alias for `formCompletionStage` for a concrete implementation of
   * CompletionStage
   */
  def fromCompletableFuture[A](cs: => CompletableFuture[A])(implicit trace: Trace): Task[A] =
    fromCompletionStage(cs)

  /**
   * WARNING: this uses the blocking Future#get, consider using
   * `fromCompletionStage`
   */
  def fromFutureJava[A](future: => Future[A])(implicit trace: Trace): Task[A] = javaz.fromFutureJava(future)

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy