0

(sort of followup to How to make a code thread safe in scala? )

I have a scala class that can inherently be called only from one thread (let's call it class ThreadUnsafeProducer); it is, however, safe to have more threads to each access exactly one object. However, the ThreadUnsafeProducer is quite memory heavy, so I don't want each thread to have one ThreadUnsafeProducer.

I want to have a given number N of ThreadUnsafeProducer objects (ideally one for each CPU).

I have lots of threads Consumer that all share the same object SharedObject.

I want to somehow use Actors model to give messages to either SharedObject or ThreadUnsafeProducer (I am not sure which) to have a given number of concurrent ThreadUnsafeProducer running. And I am quite lost in all the Akka/Actors classes.

4

1 回答 1

0

我最近发现了 Akka 路由类

http://doc.akka.io/docs/akka/2.0/scala/routing.html

它看起来真的很好,正是我需要的。如果它有效,那将是美丽的。

于 2012-05-24T10:42:57.293 回答