actors

How to limit concurrency when using actors in Scala?

I'm coming from Java, where I'd submit Runnables to an ExecutorService backed by a thread pool. It's very clear in Java how to set limits to the size of the thread pool. I'm interested in using Scala actors, but I'm unclear on how to limit concurrency. Let's just say, hypothetically, that I'm creating a web service which accepts "jobs"...

In Erlang how is using registered processes different from global variables in a traditional language?

To me they seem to be the same thing, its just that registered processes are disguised by the terminology "actors". Update: I have since seen the error in my way of thinking. I guess as I am new to Erlang I was using actors in places where they did not belong at all (is there an anti-pattern name for this somewhere) ...

Scala 2.8Beta1 Actor

Calling the !! method from one actor to another worker actor appears to keep the channel open even after the reply was received by the caller (ie: future is ready). For example, using !! to send 11 different messages from one actor to another worker actor will result in 11 messages similar to the below being shown in the mailbox of the ...

How would you explain actors to a non-programmer?

Well, the title's pretty much it: if I sat a non-techie/my mum/twelve-year old boy/cocker spaniel in front of you and asked you to explain actors to them, where would you start? I ask because my master's project involves them to a pretty large degree, and every other day someone asks me to tell them what I'm doing. When I'm talking to ot...

'Deadlock' in scala

I want to rewrite in scala the example from Sun's tutorial about concurrency in java. The original code is here: http://java.sun.com/docs/books/tutorial/essential/concurrency/deadlock.html This code is incorrect. It freezes at where the comment indicates. Could anyone correct this? Thanks in advance. import scala.actors.Actor class Pe...

Composing actors

I've implemented a Listenable/Listener trait that can be added to Actors. I'm wondering if it's possible to attach this style of trait to an actor without it having to explicitly call the listenerHandler method? Also I was expecting to find this functionality in the Akka library. Am I missing something or is there some reason that Akka ...

Scala: Why are Actors lightweight?

Forgive me if this is a stupid question, but what makes actors so lightweight? To be honest, I'm not even sure how they work. Aren't they separate threads? 'Seems I have two questions. Thanks in advance :) ...

Dependency between operations in scala actors

I am trying to parallelise a code using scala actors. That is my first real code with actors, but I have some experience with Java Mulithreading and MPI in C. However I am completely lost. The workflow I want to realise is a circular pipeline and can be described as the following: Each worker actor has a reference to another one, thus...

Scala 2.8 Actors

Hi, We're looking at using actors in our Scala code quite soon. We're also thinking of moving to Scala 2.8 in the next few weeks. We've been keeping an eye on Akka but it doesn't currently support 2.8 and plans for it have slipped from the 0.7 release to 0.8 We would like distributed, supervised actors. Is there an alternative to Akka?...

How do I rewrite a for loop with a shared dependency using actors

We have some code which needs to run faster. Its already profiled so we would like to make use of multiple threads. Usually I would setup an in memory queue, and have a number of threads taking jobs of the queue and calculating the results. For the shared data I would use a ConcurrentHashMap or similar. I don't really want to go down th...

The Scala way to use one actor per socket connection

I am wondering how it is possible to avoid one socket connection pr. thread in Scala. I have thought a lot about it, but I always end up with some code which is listening for incoming data for each client connection. The problem is that I want to develop an application which should simultanously handle perhaps a couple of thousand conne...

Scala Actors with Java interop to underlying COM libraries

I'm working on a JVM project which uses ESRI components (COM based, wrapped with JIntegra.) The client has requested the JAR files we produce work on the JVM and be accessible to Java code. I'd like to use Scala but I'm worried about how well the library will play with Scala's actors. Particularly I'm worried about the different mecha...

I'm having an issue with a scala script using 2.7.7 - Main$$anon$1$$anonfun$1$$anonfun$apply$2

This is the code I used from a book... import scala.actors.Actor._ val countActor = actor { loop { react { case "how many?" => { println("I've got " + mailboxSize.toString + " messages in my mailbox.") } } } } countActor ! 1 countActor ! 2 countActor ! 3 countActor ! "how many?" countActor ! "how many?"...

Help understanding some OpenGL stuff

I am working with some code to create a triangle that moves with arrow keys. I want to create a second object that moves independently. This is where I am having trouble, I have created the second actor, but cannot get it to move. There is too much code to post it all so I will just post a little and see if anyone can help at all. ogl_t...

Best method to peek into a Scala Actor's Mailbox

Using Scala 2.8 RC1 or newer, what is the best (easiest and/or most direct) method to "peek" at the waiting messages in an actor's mailbox (from within the same actor's act() method) in order to examine what is in the queue, without having to react/receive the messages and/or disturb the current contents of the mailbox in any way. The p...

Newbie OutOfMemory problem

I am trying to create a producer/consumer type Scala app. The LoopControl just sends a message to the MessageReceiver continually. The MessageReceiver then delegates work to the MessageCreatorActor (whose work is to check a map for an object, and if not found create one and start it up). Each MessageActor created by this MessageCreatorA...

How can Scala actors return a value in response to a message?

There are plenty of examples of actors replying with another message back to the sender, but whilst browsing the API docs I noticed the !! and !? operators which are part of the CanReply trait (which seems to be new to 2.8: http://www.scala-lang.org/archives/rc-api/scala/actors/CanReply.html). I was therefore wondering whether it was jus...

Actor pool in scala

I have a project that is actor-based and for one part of it I must use some actors that receive message after that one actor assigns to each request separately and each actor is responsible for doing its message request, so I need something like a thread pool for actors of my project, are there any features in Scala that is useful for my...

Canonical pattern reference in Actors programming model.

Hello! Is there a source, which I could use to learn some of the most used and popular practices regarding Actor-/Agent-oriented programming? My primary concern is about parallelism and distribution limited to the mentioned scheme - Actors, message passing. Should I begin with Erlang documentation or maybe there is any kind of book t...

Different Scala Actor Implementations Overview

I'm trying to find the 'right' actor implementation for my thesis. I realized there is a bunch of them and it's a bit confusing to pick one. Personally I'm especially interested in remote actors, but I guess a complete overview would be helpful to many others. This is a pretty general question, so feel free to answer just for the impleme...