Skip to content

Instantly share code, notes, and snippets.

@chris-martin
Created January 24, 2017 16:19
Show Gist options
  • Save chris-martin/dfd2a6846b86448e469f5f4e254f5dd5 to your computer and use it in GitHub Desktop.
Save chris-martin/dfd2a6846b86448e469f5f4e254f5dd5 to your computer and use it in GitHub Desktop.
trait Question[R] {
def ask(ref: ActorRef)(implicit timeout: Timeout, ct: ClassTag[R]):
Future[R] =
new AskableActorRef(ref).ask(this).mapTo[R]
def reply(r: R)(implicit context: ActorContext): Unit =
context.sender ! r
def replyWithFuture(f: Future[R])
(implicit ac: ActorContext, ec: ExecutionContext): Unit = {
val _ = f.pipeTo(ac.sender)
()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment