Scala -way for managing object pools

What is the preferred way in scala to manage object pools?

I need to create and delete large-scale objects with single-threaded (no need for synchronization). In C ++, I used an array of static objects.

What is an idiomatic and effective way to deal with it in scala?

+7
source share
1 answer

I would have wrapped him in an actor. If you are not familiar, check out Akka: http://doc.akka.io/docs/akka/2.0.3/scala/actors.html

This is a pretty good example: https://github.com/derekjw/fyrie-redis/blob/master/src/main/scala/net/fyrie/redis/ConnectionPool.scala

The actor model guarantees single-threaded access, as participants process incoming messages one at a time. This results in a very simple code inside the actor and a very simple API.

+4
source

All Articles