way for managing object pools

What is the preferred way in scala for managing object pools?

I need to create and delete large scale of objects single-threaded (no need for synchronization) . In c++ I've used array of static objects.

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


I would wrap it 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 allows you to guarantee single-threaded access because actors process incoming messages one at a time. This leads to very simple code inside the actor and a very simple API.

链接地址: http://www.djcxy.com/p/63980.html

上一篇: 指向动态分配的boost multi中的类

下一篇: 管理对象池的方式