views:

73

answers:

1

I understand that actors are a great feature and are the #1 choice for concurrency in scala, but I don't know if they would apply here.

I am creating an asynchronous server. Clients connect, send data, the server does a cpu intensive task, and then the client disconnects. There is no waiting for data - as soon as the client connects, it sends the required data to the server immediately.

I would like to use an efficient thread pool based task structure for this. Are actors even a good choice for this, since I wouldn't even be sending messages (and even if I did engineer it that way, it would only be one)? Or should I just use Java's thread pool implementation?

Edit: Now that I look at it, are you able to put code in act() and have it execute concurrently? Do you really even need a receive/react loop?

+2  A: 

Why do you not consider the data you're sending a message? That's all a message is, data. I know the examples don't make that real clear, but you can send any object across as a message. So, yes scala actor's are a good way to do this, and you could even say, designed with this in mind. However, if you disagree that your data is the message, then you can use java's concurrency package as you will.

Jim Barrows