In this example a msg is sent to an actor with the ask pattern.
The caller (sender) will immediately get back a Future from Patterns.ask.
The receiving actor of the msg will see the message as any other message,
i.e. it does not know that it was sent with ask. The receiving actor will
send back a reply using:

getSender().tell(replyMsg, getSelf());

That replyMsg will automatically complete the Future on the caller (sender)
side.

The caller stops its execution by invoking Await.result. That will block
the thread that the caller is running on (current thread) until the Future
is completed.

This means that the thread cannot be used for anything else while it is
waiting for the Future to be completed. That is a waste of resources and
the reason why we always say that Await should not be used, without
thinking thrice about it.

When the caller (sender) is an actor it is good to use the pipe to pattern
together with ask, or use tell instead of ask.

Regards,
Patrik


On Thu, Feb 12, 2015 at 5:28 AM, Krishna Kadam <[email protected]
> wrote:

> Hi All,
>        Regarding previous query this query, I have two questions,
>
> 1.  How an UntypedActor will add its reply to the Future and return this
> future to calling thread?
>
> 2.  You have mentioned current thread in docs By current thread do you
> mean current main thread or dispatcher thread?
>
>
> Please do reply, I have posted more than one threads for this queries but
> havn't got any reply? If you have any suggestions please share?
>
> Thanks & Regards
> Krishna Kadam
>
> --
> >>>>>>>>>> Read the docs: http://akka.io/docs/
> >>>>>>>>>> Check the FAQ:
> http://doc.akka.io/docs/akka/current/additional/faq.html
> >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
> ---
> You received this message because you are subscribed to the Google Groups
> "Akka User List" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/akka-user.
> For more options, visit https://groups.google.com/d/optout.
>



-- 

Patrik Nordwall
Typesafe <http://typesafe.com/> -  Reactive apps on the JVM
Twitter: @patriknw

[image: Scala Days] <http://event.scaladays.org/scaladays-sanfran-2015>

-- 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: 
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>>      Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to