Thank you for your quick reply reply Just to clearify. I am not working too
much of with the internal state. Most of the actors in my system just do
the transformation and replies. Are you suggesting that i should create one
more level of Actor to handle the //... some time consumping processs and
have that actor send the response some where when it's done?
@Override
public void onReceive(Object message) throws Exception {
if (message instanceof Input) {
Function<InputDataPoint,OutputDataPoint> process = dp -> {
//... some time consumping processs
}
Input input = (Input) message;
List<InputDataPoint> inputData = input.getData();
//List<OutputDataPoint> response=
inputData.parallelStream().map(process);
List<OutputDataPoint> response= inputData.stream().map(process);
getSender().tell(respose,getSelf());
} else unhandled(message);
}
On Thursday, May 12, 2016 at 6:29:52 AM UTC-4, Akka Team wrote:
>
> Hi Alex,
>
> As a little bit of perspective, Scala had parallel collections for ages
> (at least 4 years maybe more) which is very similar to .parallelStream().
> Nowadays the parallel collections library is stripped out of the core scala
> library. The most important reason is that parallel collections failed to
> deliver in most of the cases. While there are problems that can be
> efficiently encoded as combinators on a collection and hence can exploit
> this simple form of concurrency/parallelism, most real world use-cases
> simply do not fit this model.
>
> So, unless your problem *really* fits parallel streams I think it might
> not help you in the end. Also, remember, that an actor's state must not be
> modified from outside the actor, so whenever you use a parallelStream() you
> won't be able to directly access variables of an actor, you will need to
> send messages to it to change its state. This complicates matters and in
> the end you might not get what you wanted.
>
> -Endre
>
> On Thu, May 12, 2016 at 5:56 AM, Alex Liang <[email protected]
> <javascript:>> wrote:
>
>> I've just started experimenting with akka. (Still using akka with java8)
>> I've been working on something for a few weeks. One of the things that i am
>> not sure about is whether to use .stream() or .parallelStream(). Since
>> actors themself are already threaded. Is it beneficial to again use
>> .parallelStream() when i am doing data processsing?
>>
>> --
>> >>>>>>>>>> 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] <javascript:>.
>> To post to this group, send email to [email protected]
>> <javascript:>.
>> Visit this group at https://groups.google.com/group/akka-user.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> Akka Team
> Typesafe - Reactive apps on the JVM
> Blog: letitcrash.com
> Twitter: @akkateam
>
--
>>>>>>>>>> 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 https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.