Creates a Future from the raw com.thoughtworks.tryt.covariant.TryT
Creates a Future from the raw com.thoughtworks.tryt.covariant.TryT
Returns a Future of an asynchronous operation.
Returns a Future of a blocking operation
Returns a Future of a blocking operation that will run on executionContext
.
Returns a Future from a NIO asynchronous operation.
Returns a Future from a NIO asynchronous operation.
Given an NIO asynchronous channel,
import com.thoughtworks.future._ import scalaz.syntax.all._ import java.nio._, file._, channels._ val channel = AsynchronousFileChannel.open(Files.createTempFile(null, null), StandardOpenOption.WRITE)
when writing bytes into the channel,
val bytes = ByteBuffer.wrap("Hello, World!".getBytes(scala.io.Codec.UTF8.charSet)) val position = 0L val writeFuture: Future[java.lang.Integer] = Future.nio[java.lang.Integer](channel.write(bytes, position, _, _))
then the file size should be the number of bytes written.
writeFuture.map { numberOfBytesWritten => try { numberOfBytesWritten.toInt should be > 0 channel.size should be(numberOfBytesWritten.toLong) } finally { channel.close() } }.toScalaFuture
Returns a Future whose value is always a
.
Returns a Future whose value is always a
.
Returns a Future of an asynchronous operation like async except this method is stack-safe.
Extracts the underlying com.thoughtworks.tryt.covariant.TryT of future
Extracts the underlying com.thoughtworks.tryt.covariant.TryT of future
This unapply
can be used in pattern matching expression.
import com.thoughtworks.future.Future import com.thoughtworks.continuation.UnitContinuation val Future(tryT) = Future.now[Int](42) tryT should be(a[com.thoughtworks.tryt.covariant.TryT[UnitContinuation, _]])