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

cgta.oscala.extensions.FutureExtensions.scala Maven / Gradle / Ivy

The newest version!
package cgta.oscala
package extensions

import scala.concurrent.{ExecutionContext, Promise, Future}
import scala.util.Try


//////////////////////////////////////////////////////////////
// Copyright (c) 2014 Ben Jackman, Jeff Gomberg
// All Rights Reserved
// please contact [email protected] or [email protected]
// for licensing inquiries
// Created by bjackman @ 11/10/14 8:59 PM
//////////////////////////////////////////////////////////////

class FutureExtensions[A](val f: Future[A]) extends AnyVal {

  def tryResult(implicit ec : ExecutionContext) : Future[Try[A]] = {
    val p = Promise[Try[A]]()
    f.onComplete(t=>p.complete(Try(t)))
    p.future
  }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy