-
-
Save sslavic/163876cc22c4abf5a3ea to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.twitter.util.{Future => TwFuture} | |
import scala.concurrent.{Future => ScFuture, promise => ScPromise} | |
implicit def twFutureToScala[T](twFuture: TwFuture[T]): ScFuture[T] = { | |
val prom = ScPromise[T] | |
twFuture.onSuccess { res: T => | |
prom.success(res) | |
} | |
twFuture.onFailure { t: Throwable => | |
prom.failure(t) | |
} | |
prom.future | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.twitter.util.{ Future => TwFuture, Try => TwTry } | |
import scala.util.{Try => ScTry} | |
import scala.concurrent.{ Future => ScFuture, promise => ScPromise } | |
implicit def twTryToScalaTry[T](tw : TwTry[T]) : ScTry[T] = { | |
ScTry(tw.get) | |
} | |
implicit def twFutureToScala[T](twFuture: TwFuture[T]): ScFuture[T] = { | |
val prom = ScPromise[T] | |
twFuture.respond { t : TwTry[T] => | |
prom.complete(t) | |
} | |
prom.future | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment