public static final class AskPattern.Askable<T> extends scala.AnyVal
|Modifier and Type||Method and Description|
The ask-pattern implements the initiator side of a request–reply protocol.
public <U> scala.concurrent.Future<U> $qmark(scala.Function1<ActorRef<U>,T> replyTo, Timeout timeout, Scheduler scheduler)
?operator is pronounced as "ask".
Note that if you are inside of an actor you should prefer
as that provides better safety.
The party that asks may be within or without an Actor, since the
implementation will fabricate a (hidden)
ActorRef that is bound to a
Promise. This ActorRef will need to be injected in the
message that is sent to the target Actor in order to function as a reply-to
address, therefore the argument to the ask /
operator is not the message itself but a function that given the reply-to
address will create the message.
case class Request(msg: String, replyTo: ActorRef[Reply]) case class Reply(msg: String) implicit val scheduler = system.scheduler implicit val timeout = Timeout(3.seconds) val target: ActorRef[Request] = ... val f: Future[Reply] = target ? replyTo => (Request("hello", replyTo))
public int hashCode()
public boolean equals(java.lang.Object x$1)