actors

How is Scala "filling in" missing arguments to a case class?

When I call: actor_ ! Exit How is this being converted into a construction of: case class Exit(from: AbstractActor, reason: AnyRef) In particular, how is it that when I call this from a remote (client) actor which has been linked to a remote (server) actor, that the server receives an instance of Exit where the from property is an ...

Using scala actor framework as fork-join computation?

Is it possible, in theory, to use the Scala Actor Framework to do a kind of asynchronous divide-and-conquer computation similarly to JDK 7's Fork-Join framework? If so, how could I express an FJ problem with the framework - for example, the tutorial mergesort concept? Code snipplets are welcome. (I came to the idea based on a resource v...

Multiple actor invocation from blocking call

This is probably a simple problem to the scala educated mind but I'm still a beginner ;) I have a base actor who dispatches a task to multiple worker actors and replies it's result to a blocking external call via !? a = new a a.start println(a !? "12345") class a extends Actor { def act = { loop { react { case ms...

Is it reasonable to view highly autonomous actors as agents?

Coming from an academic background in mutli-agent systems (developed in Java using JADE) I have only been peripherally aware of the Actor concurrency paradigm. Now that I've started exploring Scala I couldn't help but be struck by the similarities between the Agent and Actor approaches. I'm very tempted to use Scala's Actor library for...

problem extending scala Actor

I m new to scala. When learning Actor, I tried to extend it to save one line of def: import scala.actors.Actor import Actor._ class Actoo(actoo: =>Unit) extends Actor { def act() {actoo} } object run extends Application { /* // this one runs well val a = new Actor { def act() { receive { case 1 => pr...

Sleeping actors?

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 ...

Scala actors: receive vs react

Let me first say that I have quite a lot of Java experience, but have only recently become interested in functional languages. Recently I've started looking at Scala, which seems like a very nice language. However, I've been reading about Scala's Actor framework in Programming in Scala, and there's one thing I don't understand. In chapt...

Calling an blocking Actor from within an Actor

Given I invoke an actor from inside react does this block the calling Actor or is it still processing other requests? class worker extends Actor() { def act() = { loop { react { msg => var foo = another_actor !? 'bar' //Block here? println(foo) } } } ...

Writing applications with Scala actors in practice

I've now written a few applications using scala actors and I'm interested in how people have approached or dealt with some of the problems I've encountered. A plethora of Message classes or !? I have an actor which reacts to a user operation and must cause something to happen. Let's say it reacts to a message UserRequestsX(id). A conti...

Writing applications with Scala actors in practice II

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 = permissionService.findPermi...

Maximum size of Actor Queues?

I'm considering using Actors in a system to wrap some storage (could be a database, could be an in-memory collection). The reason I want to do this is because I don't want calls to the store to be blocking from the code that's calling it and I intend to push a high volume of messages through. Could an actor's inbound message queue handl...

Executing a simple task on another thread in scala

I was wondering if there was a way to execute very simple tasks on another thread in scala that does not have a lot of overhead? Basically I would like to make a global 'executor' that can handle executing an arbitrary number of tasks. I can then use the executor to build up additional constructs. Additionally it would be nice if block...

Scala Remote Actor Security

What is the (or a) recommended way to implement security for Scala Remote Actors (authentication of remote nodes allowed to speak to this actor, and encryption of the contents of the discussion)? Has anyone done this; how did it work out? SSL... some Java library... some JSR... custom serialization... only VPN is going to work on this...

When are threads created for scala actors

After reading about using react in an actor, I thought reacts would share the same thread when there weren't multiple reacts pending, but it isn't the case: import scala.actors.Actor import scala.actors.Actor._ class SleepyReactor extends Actor { def act() { loop { react { case x => { println("reacting to...

How to control TCP_NODELAY setting for Scala remote actor ?

I'm using Scala's remote actors, but round-trip time (even of a trivial message) is 80ms, presumably due to underlying socket not having the TCP/IP Nagle algorithm disabled (also known as TCP_NODELAY), or at least that's what someone with some experience with Java RMI informs me. All I'm doing in the client to get a link to the remote a...

Scala Actors - Worst practices?

Hi, I feel a bit insecure about using actors in Scala. I have read documentation about how to do stuff..but I guess I would also need some DON'T rules in order to feel free to use them. I think I am afraid that I will use them in a wrong way and I will not even notice it. Can you think of something, that, if applied, would result in ...

Easiest way to do idle processing in a Scala Actor?

I have a scala actor that does some work whenever a client requests it. When, and only when no client is active, I would like the Actor to do some background processing. What is the easiest way to do this? I can think of two approaches: Spawn a new thread that times out and wakes up the actor periodically. A straight forward approach,...

How to designate a thread pool for actors

I have an existing java/scala application using a global thread pool. I would like to start using actors in the project but would like everything in the app using the same pool. I know I can set the maximum number of threads that actors use but would prefer sharing the thread pool. Is this necessary/reasonable, and is it possible to de...

Singleton Scala actor?

Simple question. Can I do this: object Xyz extends Actor { ... } or do Actors have to be classes with instances? ...

Symbols or Case Classes for sending messages to Scala Actors?

In the Scala actor examples I have seen where a parameterless message is sent to an actor (such as this), case classes (or case objects) have been created and then used as messages. Symbols work just as well and look a bit neater and, after reading a book on Erlang, seem more natural. I assume that symbol equality would work for remote a...