actor

Scala pattern matching confusion with Option[Any]

。_饼干妹妹 提交于 2019-12-03 06:32:46
问题 I have the following Scala code. import scala.actors.Actor object Alice extends Actor { this.start def act{ loop{ react { case "Hello" => sender ! "Hi" case i:Int => sender ! 0 } } } } object Test { def test = { (Alice !? (100, "Hello")) match { case i:Some[Int] => println ("Int received "+i) case s:Some[String] => println ("String received "+s) case _ => } (Alice !? (100, 1)) match { case i:Some[Int] => println ("Int received "+i) case s:Some[String] => println ("String received "+s) case _

Is it good to put jdbc operations in actors?

点点圈 提交于 2019-12-03 06:01:08
问题 I am building a traditional webapp that do database CRUD operations through JDBC. And I am wondering if it is good to put jdbc operations into actors, out of current request processing thread. I did some search but found no tutorials or sample applications that demo this. So What are the cons and pros? Will this asynchonization improve the capacity of the appserver(i.e. the concurrent request processed) like nio? 回答1: Whether putting JDBC access in actors is 'good' or not greatly depends upon

Sleeping actors?

本小妞迷上赌 提交于 2019-12-03 04:25:08
问题 What's the best way to have an actor sleep? I have actors set up as agents which want to maintain different parts of a database (including getting data from external sources). For a number of reasons (including not overloading the database or communications and general load issues), I want the actors to sleep between each operation. I'm looking at something like 10 actor objects. The actors will run pretty much infinitely, as there will always be new data coming in, or sitting in a table

libgdx difference between sprite and actor

依然范特西╮ 提交于 2019-12-03 04:10:13
问题 I'm just going through the javadoc and various tutorials on libgdx and I'm at the stage of trying to figure out differences between various concepts that seem similar to me or provide similar capabilities in libgdx. At first I thought scene2d was about creating interactive items such as menus, etc but various tutorials I'm reading use scene2d/actors for the main game items (i.e. the player, etc) and others just use sprites. What exactly is the difference between using Sprite and Actor (i.e.

Simple Scala actor question

情到浓时终转凉″ 提交于 2019-12-03 03:53:27
I'm sure this is a very simple question, but embarrassed to say I can't get my head around it: I have a list of values in Scala. I would like to use use actors to make some (external) calls with each value, in parallel. I would like to wait until all values have been processed, and then proceed. There's no shared values being modified. Could anyone advise? Thanks There's an actor-using class in Scala that's made precisely for this kind of problem: Futures. This problem would be solved like this: // This assigns futures that will execute in parallel // In the example, the computation is

Using Futures in Akka Actors

China☆狼群 提交于 2019-12-03 03:15:31
I'm just starting to learn Akka Actors in Scala. My understanding is that messages received by an Actor are queued in an Actor's mailbox, and processed one at a time. By processing messages one at a time, concurrency issues (race conditions, deadlocks) are mitigated. But what happens if the Actor creates a future to do the work associated with a message? Since the future is async, the Actor could begin processing the next several messages while the future associated with the prior message is still running. Wouldn't this potentially create race conditions? How can one safely use futures within

Which Actor model library/framework for python and Erlang-like? [closed]

帅比萌擦擦* 提交于 2019-12-03 03:03:05
问题 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 2 months ago . I am looking for an easy-to-learn Actor library or framework for Python 2.x. I have tried Candygram and Twisted but I did not like them. I'd like something that will be easy to extend to suppero Greenlet (= stackless python). Candygram is too old. Twisted is too complicated. Gevent: it is unclear if it can

No configuration setting found for key 'akka.version'

匿名 (未验证) 提交于 2019-12-03 03:03:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am learning akka-remoting and this is how my project looks The project structure looks like project/pom.xml project/mymodule/pom.xml project/mymodule/src/main/resources/application.conf project/mymodule/src/main/scala/com.harit.akkaio.remote.RemoteApp.scala project/mymodule/src/main/scala/com.harit.akkaio.remote.ProcessingActor.scala When I run my project on command-line , I see $ java -jar akkaio-remote/target/akka-remote-jar-with-dependencies.jar com.harit.akkaio.remote.RemoteApp Hello:com.harit.akkaio.remote.RemoteApp Exception in

stacking multiple traits in akka Actors

老子叫甜甜 提交于 2019-12-03 02:57:26
I'm creating multiple traits which extend Actor. Then I want to create an actor class which uses some of these traits. However, I'm not sure how to combine the receive methods from all traits in the receive method of the Actor class. Traits: trait ServerLocatorTrait extends Actor { def receive() = { case "s" => println("I'm server ") } } trait ServiceRegistrationTrait extends Actor { def receive() = { case "r" => println("I'm registration ") } } The Actor: class FinalActor extends Actor with ServiceRegistrationTrait with ServerLocatorTrait { override def receive = { super.receive orElse ??? <-

Akka remote actor server discovery

流过昼夜 提交于 2019-12-03 02:52:36
I would like to deploy a remote actors software made with akka on a cluster. The system is composed of several worker nodes and a single master node. The problem is that I cannot know in advance the IP address of the cluster nodes (but I know they are all part of the same subnetwork). So, I need a nice way of discovering the IP address of everyone after startup, to create the correct actor refs on each node. I am looking for a ligtweight solution (I just need it for the initial setup) distributed under any free software license. A while ago I created a prototype that's intended to solve your