Created
March 2, 2015 03:45
-
-
Save jstultz/65636f681b3e4c5d798d 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
def toScalaFuture[A](twitterFuture: Future[A]): ScalaFuture[A] = { | |
val promise = ScalaPromise[A]() | |
twitterFuture.respond { | |
case Return(a) => promise.success(a) | |
case Throw(e) => promise.failure(e) | |
} | |
promise.future | |
} | |
def fromScalaFuture[A](scalaFuture: ScalaFuture[A])(implicit executor: ExecutionContext): Future[A] = { | |
val promise = Promise[A]() | |
scalaFuture.onComplete { | |
case ScalaSuccess(a) => promise.setValue(a) | |
case ScalaFailure(e) => promise.setException(e) | |
} | |
promise | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment