27 feb 2014 kl. 02:34 skrev [email protected]:
> Hello,
>
> If you do the following:
> future1 map { r => agent.send(1) }
> future2 map { r => agent.send(2) }
>
> The order of the sends will be determined by the length of future1 and
> future2.
Yes, but why should that matter given that you don’t care when future{1,2} are
actually executed?
> I would expect something like
> agent.sendOff(future1 map { r => 1 })
> agent.sendOff(future2 map { r => 2 })
The Future API also supports sequencing operations, which seem more appropriate
to use in this case:
val future3 = future1.andThen(agent.send(1)).flatMap(_ =>
future2).andThen(agent.send(2))
future3 completes with the value of future2, but only after the second
agent.send() has been executed.
Regards,
Roland
>
> In a way the sends are applied in order.
>
> Regards,
> partycoder
>
> On Thursday, February 13, 2014 3:43:14 AM UTC-8, rkuhn wrote:
> Hi partycoder,
>
> in which way does your code cause an ordering problem? What do you observe
> and why is that not as it should be?
>
> Regards,
>
> Roland
>
> 12 feb 2014 kl. 06:36 skrev [email protected]:
>
>> Hello,
>>
>> I have a question.
>>
>> val f = some future
>> val a = Agent(some type)
>>
>> // This may cause an ordering problem
>> f map { result => a.send(result) }
>>
>> How do I use agent.send/sendOff using futures?
>>
>> Regards
>>
>> --
>> >>>>>>>>>> Read the docs: http://akka.io/docs/
>> >>>>>>>>>> Check the FAQ: http://akka.io/faq/
>> >>>>>>>>>> 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/groups/opt_out.
>
>
>
> Dr. Roland Kuhn
> Akka Tech Lead
> Typesafe – Reactive apps on the JVM.
> twitter: @rolandkuhn
>
>
>
> --
> >>>>>>>>>> Read the docs: http://akka.io/docs/
> >>>>>>>>>> Check the FAQ: http://akka.io/faq/
> >>>>>>>>>> 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/groups/opt_out.
Dr. Roland Kuhn
Akka Tech Lead
Typesafe – Reactive apps on the JVM.
twitter: @rolandkuhn
--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ: http://akka.io/faq/
>>>>>>>>>> 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/groups/opt_out.