Re: [akka-user] Agents and futures

2014-02-27 Thread partycoder
Adding more detail, this is just stub code, may actually not compile, but just for illustration: class A extends Actor { val cache = Agent(42) val backend: ActorRef // reference to the backend def receive: Receive = { case Read = cache.future() pipeTo sender case

Re: [akka-user] Agents and futures

2014-02-27 Thread Akka Team
Hi, In general I would consider Agents to be an advanced feature. It might be tempting to use them since they look simple but I recommend using Actors instead whenever it is possible. While there are important use-cases of Agents they are for fairly specific scenarios. -Endre On Thu, Feb 27,

Re: [akka-user] Agents and futures

2014-02-26 Thread partycoder
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. I would expect something like agent.sendOff(future1 map { r = 1 }) agent.sendOff(future2 map { r = 2 }) In a way

Re: [akka-user] Agents and futures

2014-02-26 Thread partycoder
For example: f1 map { result = agent.send(1) } f2 map { result = agent.send(2) } The order of the sends depends on how long f1 and f2 take. I would like an API similar to sendOff, accepting futures: agent.sendOff(f1 map { 1 }) agent.sendOff(f2 map { 2 }) In this way, the results of f1 and f2

Re: [akka-user] Agents and futures

2014-02-26 Thread Roland Kuhn
27 feb 2014 kl. 02:34 skrev partyco...@gmail.com: 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

Re: [akka-user] Agents and futures

2014-02-13 Thread Roland Kuhn
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 partyco...@gmail.com: Hello, I have a question. val f = some future val a = Agent(some type) // This may cause