actor

Incremental processing in an akka actor

江枫思渺然 提交于 2019-12-09 18:13:40
问题 I have actors that need to do very long-running and computationally expensive work, but the computation itself can be done incrementally. So while the complete computation itself takes hours to complete, the intermediate results are actually extremely useful, and I'd like to be able to respond to any requests of them. This is the pseudo code of what I want to do: var intermediateResult = ... loop { while (mailbox.isEmpty && computationNotFinished) intermediateResult = computationStep

Waiting on multiple Akka FSM messages

≯℡__Kan透↙ 提交于 2019-12-09 13:40:07
问题 I have an Akka FSM actor that runs the following pseudocode after receiving a message while in ReadyState lookupA ! Wrapper(Lookup("A")) lookupB ! Wrapper(Lookup("B")) lookupC ! Wrapper(Lookup("C")) goto(LookingUpDataState) using DataFound(a = None, b = None, c = None) The actor then waits for responses which can be either FullResult[T] (extending ServiceResult[T] ) or Empty (extending ServiceResult[Nothing] ). Successful lookup results are used to populate the DataFound instance's fields and

How to store state in an F# Akka.NET Actor?

二次信任 提交于 2019-12-09 10:20:28
问题 In C# ReceiveActor s I can just have state as private fields in the class. How should I do this in an idiomatic way with the F# API? Is this a good idea? Any alternatives? let handleMessage (mailbox: Actor<'a>) msg = let mutable i = 1 match msg with | Some x -> i <- i + x | None -> () 回答1: The way you've proposed is entirely appropriate as a means of storing the state within the actor. The concurrency constraints of only processing 1 message at any time means that it's not possible to get

Why is the actor “ask” pattern considered an anti-pattern or “code smell?”

我的未来我决定 提交于 2019-12-09 09:16:01
问题 From what I've gathered, the "ask" pattern is considered a bad practice and should be avoided. Instead, the recommended pattern is the "actor per request" model. However, this doesn't make sense to me, as the "ask" pattern does exactly this - it creates a lightweight actor per request. So why is this then considered bad, especially when futures are far more composable and are able to more elegantly handle the collation of multiple send/receives? 回答1: From Akka docs: "There are performance

Writing applications with Scala actors in practice II [closed]

送分小仙女□ 提交于 2019-12-09 06:45:00
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed last year . Because my first question was so long, I'm asking this as a separate question. It's another one about the architecture of an actor-based application. Keeping track of message paths through an Application Let's take a piece of Java code: public void deleteTrades(User user, Date date) { PermissionSet ps =

Which ThreadPool in Java should I use?

二次信任 提交于 2019-12-09 05:38:06
问题 There are a huge amount of tasks. Each task is belong to a single group. The requirement is each group of tasks should executed serially just like executed in a single thread and the throughput should be maximized in a multi-core (or multi-cpu) environment. Note: there are also a huge amount of groups that is proportional to the number of tasks. The naive solution is using ThreadPoolExecutor and synchronize (or lock). However, threads would block each other and the throughput is not maximized

Can Verilog/Systemverilog/VHDL be considered actor oriented programming languages?

二次信任 提交于 2019-12-09 04:22:28
These languages provide modules which are inherently concurrent and can handle asynchronous messages pretty neat (through ports). Keeping aside the fact that they cannot spawn module instances at runtime, do they qualify as actor based programming languages? Thanks EDIT: What I'm really looking for is how well the language semantics can be used to "model" actors, rather than how a simulator would handle the code (of course, they are all event-driven underneath; and further down, we end up with transistors :-) ). So if I create a bunch of Ip4Routers like this, module Ip4Router ( inout interface

Is F# really faster than Erlang at spawning and killing processes?

萝らか妹 提交于 2019-12-09 04:13:13
问题 Updated: This question contains an error which makes the benchmark meaningless. I will attempt a better benchmark comparing F# and Erlang's basic concurrency functionality and inquire about the results in another question. I am trying do understand the performance characteristics of Erlang and F#. I find Erlang's concurrency model very appealing but am inclined to use F# for interoperability reasons. While out of the box F# doesn't offer anything like Erlang's concurrency primitives -- from

How can I get Fibonacci(n) in an efficient way with Scala Actor?

风格不统一 提交于 2019-12-08 14:25:29
The algorithm is just like this. def fib(x: Int): BigInt = { x match { case 1 => BigInt(1) case 2 => BigInt(1) case x => fib(x-1) + fib(x-2) } } I try to make the algorithm parallel with Actor in Scala. But my code is extremely slow compare with the one without Actor! Is there a good way to make it work? For not large size of n , the serial code will always be faster (Much much faster in cases of tail recursion). This is because calling a new function will be faster than starting a new actor. Plus there will contention among threads and context switches. In the below code, I start a new actor

How to add a scala library to eclipse

时间秒杀一切 提交于 2019-12-08 11:28:13
问题 I am trying to add this Scala Library into Eclipse so as to add available functions I can use on Actors. I've downloaded the file and extracted it and tried adding it to my workspace in the project explorer, but when I try, Eclipse tells me it can't find any projects in the file. I'm sure that there is a tutorial or something online that explains exactly how to do this, but like I said, I'm not sure about all the terminology, so I don't know what to search for to get the result I want. 回答1: