actor

understanding threadedness of actors in scala

孤者浪人 提交于 2019-12-12 10:42:28
问题 I've been told that (Scala) Actors never actually perform two operations at the same time, which suggests that the act (or react? or receive?) method is inherently synchronized. I know a long operation in an act method can cause blocking issues, and I assume that access to the message queue must be synchronized in some way... but... What was suggested is that an actor receiving messages telling it to increment an internal counter would increment the counter in a threadsafe way. That no two

what could be the best alternative to Multi-threading? [closed]

爱⌒轻易说出口 提交于 2019-12-12 08:44:48
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 4 years ago . Currently we are using threads in our application(Java). But there will be some 1000 (or more) threads created at a time.This threads should process the data and store it in db. This is consuming more memory and I/O. What could be the best alternative for this?. Scalability

Dependency injection with Akka

巧了我就是萌 提交于 2019-12-12 08:36:23
问题 I use Guice in my application quite a lot. Recently i start to learn akka actors and felt like refactoring my application with it. However upfront i am already wondering how all my guice will work with actors. I went on searching on google and it is kinda a bit messy. The most up to date docs that i have found on the subject are theses: http://letitcrash.com/post/55958814293/akka-dependency-injection http://eng.42go.com/tag/guice/ which do not advocate same thing. I must confess i still need

implicitly logging messages received by an actor in scala

拜拜、爱过 提交于 2019-12-12 04:36:09
问题 I am new to this fancy language scala and I am trying to create a library for logging scala actors. My library has a class Logger which extends the Actor class. So any Scala application which uses actor model can extend from this class instead or the Actor class for added logging functionality. Eg. class MyClass extends Logger. In my Logger class I have implemented the logic that whenever someone sends a message to some actor it is logged by the log file of the sending actor. For this,

Use akka actors to traverse directory tree

ε祈祈猫儿з 提交于 2019-12-12 04:34:31
问题 I'm new to the actor model and was trying to write a simple example. I want to traverse a directory tree using Scala and Akka. The program should find all files and perform an arbitrary (but fast) operation on each file. I wanted to check how can I model recursion using actors? How do I gracefully stop the actor system when the traversal will be finished? How can I control the number of actors to protect against out of memory? Is there a way to keep the mailboxes of the actors from growing

Starvation of Akka actors who participate in a sequence process

廉价感情. 提交于 2019-12-12 03:53:42
问题 Bisuness Logic We have the following business logic to accomplish: 1 million times do: download the file in index i unzip the file extract some info from the file delete the file Current Akka solution The Akka solution that we have at the moment creates 1 million actors who are responsible for one file to download and once they are done they create an actor to take care of steps 2,3,4. The problem Once we run the process, we came across the situation where the Akka gives top priority to the

How to use scala actors

梦想的初衷 提交于 2019-12-12 03:07:27
问题 How to solve this using scala Actors: I have a program that finds out the frequencies of identifiers in files under a given path. The encoding assumed is UTF-8. I want to solve the same problem with scala actors. //program to find frequencies of identifiers import java.io._ import java.util.concurrent._ import java.util.concurrent.atomic._ object Main { // visit all files in dir def processDirectory(dir: File, visit: (File) => Unit) { for (f <- dir.listFiles) if (f.isDirectory)

Is it OK to use `scala.actors.Actor` object in an Android application?

左心房为你撑大大i 提交于 2019-12-12 01:08:41
问题 I know that it works, just checked. I'm wondering about the system not being able to free memory or the application "hanging" in the background or such things. import scala.actors.Actor import android.util.Log object Player extends Actor { start def act { loop { react { case x => Log.v("actor", "received: " + x) } } } } Actors are so much more graspable than concurrency using regular threads. I guess scala.actors is build upon JVM threads, so maybe it's as legal as using normal threads in

Akka PoisonPill wil it kill descendent of its children?

可紊 提交于 2019-12-11 23:17:32
问题 I am using poison pill to kill children (Bx) actor of an actor (A). Each children have another children (Cx) and beyond. So it would like A -> B1 -> C1,C2,C3 -> Dx . Is it enough if I just send PoisonPill to actor B, then it will kill descendent actors below? Thanksa 回答1: Yes, once the actor receives PoisonPill message, it stop taking anymore messages and send stop to child actors. Its clear from actor lifecycle that the parent actor will kill any child actors during preRestart and wait for

Akka synchronizing timestamped messages from several actors

蓝咒 提交于 2019-12-11 18:49:27
问题 Imagine the following architecture. There is an actor in akka that receives push messages via websocket. They have a timestamp and interval between those timestamps is 1 minute. Though the messages with the same timestamp can arrive multiple times via websocket. And then this messages are being broadcasted to as example three further actors (ma). They calculate metrics and push the messages further to the one actor(c). For ma I defined a TimeSeriesBuffer that allows writing to the buffer only