Reputation: 95
I'm working with scala and akka actors and have not found a way to manage processor cores to handle parallelism level, is this possible using akka? or is transparent to the programmer?.
Upvotes: 3
Views: 915
Reputation: 127971
I don't know what exactly you mean under "managing processor cores", so I assume you wanted to ask if it is possible to control threads of execution in Akka. The direct control (i.e. spawning them with Thread.start()
and using them for message processing is impossible, but still Akka is very flexible when it comes to thread management configuration.
On the lowest level Akka uses Dispatcher
s which bind actors to underlying thread pools. For example, default executor in Akka uses ForkJoinPool
for all message processing. Dispatchers can be default for an ActorSystem
or they can be specified on a per-actor basis; this is explained extensively in the official documentation.
So you can say that Akka manages threads transparently for the programmer, but if you really want to tweak its behavior, it is always possible to do so with proper configuration.
Upvotes: 3
Reputation: 17831
An Akka MessageDispatcher is the way you control the number of threads used in akka. All MessageDispatcher implementations are also an ExecutionContext, which means that they can be used to execute arbitrary code, for instance Futures.
See http://doc.akka.io/docs/akka/snapshot/scala/dispatchers.html
Upvotes: 2