actor

Akka Routing: Reply's send to router ends up as dead letters

允我心安 提交于 2019-12-01 21:38:50
I'm playing around with Actor Routing and I can't send a reply back to the router so that another actor in the routing list can pick this up. I'm using: sender.tell([Message], context.parent) to reply to the router as according to akka docs, routed actors set the sender to themselves and their parent is the actual router when replying it will give the following message in the console: [INFO] [12/13/2013 11:19:43.030] [StarBucks-akka.actor.default-dispatcher-2] [akka://StarBucks/deadLetters] Message [net.addictivesoftware.starbucks.MakeCoffee$] from Actor[akka://StarBucks/user/Melanie#

How to overload bang(!) operator in Scala Actor model?

*爱你&永不变心* 提交于 2019-12-01 20:44:39
In an Actor model implementation in Scala, can we override the bang(!) operator. Can we modify the operation of message passing by overloading this operator? Example scenario: I need to include logging of information when any actor invokes another actor by passing a message. So by overloading the message pass(!) operator, Can I track the message passing between different actors and avoid including logger statement for every actor message passing call? In an Actor model implementation in Scala, can we override the bang(!) operator. You can, but I would strongly recommend against it. Example

Go routine 编排框架:oklog/run 包

无人久伴 提交于 2019-12-01 17:22:54
目录 Go routine 编排框架:oklog/run 包 问题引入 oklog/run 包介绍 使用例子 参考资料 Go routine 编排框架:oklog/run 包 问题引入 oklog/run 包提供了一套非常简单、易用的 Go routine 编排框架。在介绍 oklog/run 前,我们先考虑以下问题: 假设我们有四个 Go routine 组件,如图所示,分别是运行一个状态机 sm.Run 、启动一个 HTTP 服务器、执行定时任务 cronJobs(sm) 读取状态机状态、和运行信号监听器。每个 Go routine 组件互相独立运行。 问题在于,我们如何将各个组件作为一个整体运行,并有序地结束? 对于每一个 Go routine 组件,我们都有相应的办法来执行结束操作。状态机通过 Context 对象,HTTP 服务器通过调用 Listener 的 Close 方法,定时任务和监听器通过 channel。当一个组件结束的时候,需要通知其他组件有序执行结束操作。这个问题的解决方法可以用 Actor 模型来描述。每个 Go routine 都是一个 actor,互相独立,互相之间只能通过 message 通信。oklog/run 包实现了 Actor 模型,能非常简洁的实现 Go routine 编排功能。 oklog/run 包介绍 oklog/run

Does Akka support in-process messaging without object serialization?

こ雲淡風輕ζ 提交于 2019-12-01 17:16:11
Looking to use Akka Actors to communicate events between Java threads in the same JVM. Some of these events contain large objects (10-100Mb). I want to avoid serializing these objects while saving memory space by passing only a reference to the object; does Akka support this? I understand it's possible to implement a custom Akka serializer, and that could be a solution, but beyond that I don't know much else about the framework. Akka treats local message passing as an optimization, bypassing the remoting machinery which includes the message serializer. See location transparency . 来源: https:/

Does Akka support in-process messaging without object serialization?

谁说胖子不能爱 提交于 2019-12-01 16:09:56
问题 Looking to use Akka Actors to communicate events between Java threads in the same JVM. Some of these events contain large objects (10-100Mb). I want to avoid serializing these objects while saving memory space by passing only a reference to the object; does Akka support this? I understand it's possible to implement a custom Akka serializer, and that could be a solution, but beyond that I don't know much else about the framework. 回答1: Akka treats local message passing as an optimization,

Akka control threadpool threads

牧云@^-^@ 提交于 2019-12-01 14:09:15
Potentially a very silly question-- Is it possible to customize Akka/Scala actors such that you control the threads that are used by the actors? e.g. can you initialize your own set of threads to be used in the thread pool, or otherwise control/modify the threads? In Akka, the thread pool is managed via a MessageDispatcher instance. You can set the dispatcher you want to actors easily: class MyActor( dispatcher: MessageDispatcher ) extends Actor { self.dispatcher = dispatcher ... } To provide your own dispatcher, you can extend akka.dispatch.MessageDispatcher (see existing dispatchers

libGdx How to use images or actor as body

寵の児 提交于 2019-12-01 10:37:31
I gone through the libGdx wiki/tutorial but I didn't find example to use an image or an actor as a physics body. In my game I am adding an actor to the stage. But I want to add this actor or sprite image as physics body. I have to drag this actor and even want to detect collision with other bodies. please give me reference if you have. Thanks This is a bit tricky. You don't use an image or an Actor as a physics body. You will need to implement something like a new "PhysicsActor" which extends Actor. This Physics actor will have a body as a property and will be the bridge between your libgdx

Akka control threadpool threads

自作多情 提交于 2019-12-01 10:35:34
问题 Potentially a very silly question-- Is it possible to customize Akka/Scala actors such that you control the threads that are used by the actors? e.g. can you initialize your own set of threads to be used in the thread pool, or otherwise control/modify the threads? 回答1: In Akka, the thread pool is managed via a MessageDispatcher instance. You can set the dispatcher you want to actors easily: class MyActor( dispatcher: MessageDispatcher ) extends Actor { self.dispatcher = dispatcher ... } To

libGdx How to use images or actor as body

你说的曾经没有我的故事 提交于 2019-12-01 08:07:45
问题 I gone through the libGdx wiki/tutorial but I didn't find example to use an image or an actor as a physics body. In my game I am adding an actor to the stage. But I want to add this actor or sprite image as physics body. I have to drag this actor and even want to detect collision with other bodies. please give me reference if you have. Thanks 回答1: This is a bit tricky. You don't use an image or an Actor as a physics body. You will need to implement something like a new "PhysicsActor" which

How do I kill a RemoteActor?

社会主义新天地 提交于 2019-12-01 06:32:46
Not sure whether I am missing something. When making an actor remote, the main method does not terminate. Here is a snippet that demonstrates the problem. import scala.actors._ import scala.actors.remote._ object TestMe { def main(args : Array[String]) : Unit = { object jim extends DaemonActor { // comment out these two lines and the application will terminate RemoteActor.alive(12345) RemoteActor.register('jim,this) def act { loop { receive { case 'quit => println("\nquiting") exit('normal) case any => println(any) } } } } jim.start jim ! "hello" jim ! 'quit } } Put your .alive and .register