implicit final class Askable[T] extends AnyVal
- Alphabetic
- By Inheritance
- Askable
- AnyVal
- Any
- by any2stringadd
- by StringFormat
- by Ensuring
- by ArrowAssoc
- Hide All
- Show All
- Public
- All
Instance Constructors
- new Askable(ref: RecipientRef[T])
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- Any
-
final
def
##(): Int
- Definition Classes
- Any
- def +(other: String): String
- def ->[B](y: B): (Askable[T], B)
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- Any
-
def
?[U](replyTo: (ActorRef[U]) ⇒ T)(implicit timeout: Timeout, scheduler: Scheduler): Future[U]
The ask-pattern implements the initiator side of a request–reply protocol.
The ask-pattern implements the initiator side of a request–reply protocol. The
?
operator is pronounced as "ask" (and a convenience symbolic operation kept since the previous ask API, if unsure which one to use, prefer the non-symbolic method as it leads to fewer surprises with the scope of thereplyTo
function)Note that if you are inside of an actor you should prefer ActorContext.ask 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 scala.concurrent.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)))
Note: it is preferrable to use the non-symbolic ask method as it easier allows for wildcards for the
ActorRef
. -
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
ask[U](replyTo: (ActorRef[U]) ⇒ T)(implicit timeout: Timeout, scheduler: Scheduler): Future[U]
The ask-pattern implements the initiator side of a request–reply protocol.
The ask-pattern implements the initiator side of a request–reply protocol.
Note that if you are inside of an actor you should prefer ActorContext.ask 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 scala.concurrent.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.ask(replyTo => (Request("hello", replyTo))) // alternatively val f2: Future[Reply] = target.ask(Request("hello", _)) // note that the explicit type on f2 is important for the compiler // to understand the type of the wildcard
- Annotations
- @silent()
- def ensuring(cond: (Askable[T]) ⇒ Boolean, msg: ⇒ Any): Askable[T]
- def ensuring(cond: (Askable[T]) ⇒ Boolean): Askable[T]
- def ensuring(cond: Boolean, msg: ⇒ Any): Askable[T]
- def ensuring(cond: Boolean): Askable[T]
- def formatted(fmtstr: String): String
-
def
getClass(): Class[_ <: AnyVal]
- Definition Classes
- AnyVal → Any
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- val ref: RecipientRef[T]
-
def
toString(): String
- Definition Classes
- Any
- def →[B](y: B): (Askable[T], B)