actors

Proper way to access shared resource in Scala actors

In Java, one would synchronize methods or blocks that access a shared resource that is needed in a multi-threaded environment. I'm wondering how the "Scala Actors" way of doing this would work. Suppose I have a connection pool of java.sql.Connection objects that I wish to provide thread-safe access to. I implement it as an actor that ...

garbage collecting scala actors

Scenario: I have this code: class MyActor extends Actor { def act() { react { case Message() => println("hi") } } } def meth() { val a = new MyActor a.start a ! Message() } is the MyActor instance garbage collected? if not, how do i make sure it is? if I create an ad-hoc actor (with the 'actor' method), ...

Actor based development - implementation questions

Hello, it's my first message here and I'm glad to join this community. It looks like that everything is now going towards multi-thread development. Big fishes say that it won't take longer to reach hundreds of cores. I've recently read about actor based development and how wonderful message passing is to handle concurrent programming. ...

Thread monitoring for scala actors

Is there a way to monitor how many threads are actually alive and running my scala actors ? ...

When should one use actors to solve a concurrency problem?

I have been looking at the Actor Model for a while now. To me it seems to be just another approach towards concurrent programming with its own upsides and downsides. It certainly does not guarantee deadlock-free environment. A can wait for a message from B while B waits for a message from A. I don't know if we can say the actors approac...

Getting the correct scala actor sender reference when sending from an different class

Within my actor I have to create a class which sends a message to another actor. The other actor should reply back to actor A class A extends Actor { val b = new B b.start val i = new DefaultHandler() { override def fun(a: String) = { b ! payload } } someotherclass.registerHandler(i) def act = { loop {...

Possible to make a producer/consumer obj in Scala using actors 'threadless' (no receive...)?

So I want to write some network code that appears to be blocking, without actually blocking a thread. I'm going to send some data out on the wire, and have a 'queue' of responses that will come back over the network. I wrote up a very simple proof of concept, inspired by the producer/consumer example on the actor tutorial found here: ...

Using Scala Actors to create sth like a Pipeline

Hello I am struggling with the following problem for a week by now and need some advice. def query(title: String): List[Search] // query("Terminator") => ["Terminator I", "Terminator II", "Terminator 1984", etc...] def searchIMDB(s: Search): List[SearchResult] def searchTMDB(s: Search): List[SearchResult] def filterRedundantSearchR...

Any Open Source examples of using PLActorKit?

I've intrigued by Plausible Labs PLActorKit: http://code.google.com/p/plactorkit/ But the documentation just has single single Echo example. Before diving into it further I'm curious if there are any open source projects using PLActorKit I can take a look at. ...

Does it make sense to use a pool of Actors?

I'm just learning, and really liking, the Actor pattern. I'm using Scala right now, but I'm interested in the architectural style in general, as it's used in Scala, Erlang, Groovy, etc. The case I'm thinking of is where I need to do things concurrently, such as, let's say "run a job". With threading, I would create a thread pool and a...

Using the actor model in web applications

I'm looking to create a web application that's very modular, and was pointed to the actor model by a friend. After investigating it a little, I realised that developing just the back-end using actors wasn't a bad idea at all, but I also came to the conclusion that having client-side actors would be useful: rather than create pages which ...

scala actors: long running io operations

Hi! I have quite some trouble with actors which contain long running operations, in my case persistent socket connections. Here is some test code which runs fine if I create less than four Server instances, but if I create more instances, I always end up with only three or sometimes four concurrent socket connections, because the other o...

Strange GC behaviour of Scala actors application

I have an application which uses rather a lot of actors: 25,000 to be precise. It uses Scala 2.7.7 and is running on jdk6_u18. It basically listens to and processes market data and has very little state. It starts at 8.02am every day and within the hour it has crashed with an OutOfMemoryError. "Aha" you say, "you have a memory leak!" Ex...

Any good implementation of Actors for C#?

Is there any good implementation of actors concurrency model for .net/c#? I have to optimize a c# routine and i think that actors model fits perfectly as a solution for my problem. Unfortunately i have experience only with scala implementation. ...

Strange behavior: Scala Actors 2.7.7 vs. 2.8-Snapshot

I'm an 18 years old trainee and I'm discovering scala which I like very much :-). To get familiar with the scala actors I wrote a small simulation with some gears and one controller. The ActorApplication creates N gears with random speed. The controller calculates a synchronization speed and starts the gear-actors. The gears synchronize ...

Is F# really faster than Erlang at spawning and killing processes?

Updated: This question contains an error which makes the benchmark meaningless. I will attempt a better benchmark comparing F# and Erlang's basic concurrency functionality and inquire about the results in another question. I am trying do understand the performance characteristics of Erlang and F#. I find Erlang's concurrency model ve...

blocking channels vs async message passing

I've noticed two methods to "message passing". One I've seen Erlang use and the other is from Stackless Python. From what I understand here's the difference Erlang Style - Messages are sent and queued into the mailbox of the receiving process. From there they are removed in a FIFO basis. Once the first process sends the message it is fr...

Scala Actors suspends unexpected when connecting to a database

I have a problem with my understanding of the standard actor library in Scala. In the code below I have created a simple swing, which basically should test if it is able to connect to a postgreSQL server. However it doesnt make it that far, I use Actors since the UI otherwise would freeze up while doing the work needed to connect to the ...

Scala Actors: Different behavior on JRE 1.5 and 1.6

My simulation is using actors and Scala 2.8-Snapshot. In Java JRE 1.5 it runs well - all 40 gears (actors) are working simultaneously. Using Java JRE 1.6 only 3 gears are working simultaneously. I tested it with and without GUI: both give same result. My simulation with GUI is available on github: http://github.com/pmeiclx/scala_gear_si...

How can I add scala actors to an existing program without interfering with the normal termination behavior?

This program, after executing main(), does not exit. object Main { def main(args: Array[String]) { ... // existing code f() ... // existing code } def f() { import scala.actors.Actor._ val a = actor { loop { react { case msg: String => Syst...