chrisvest / stormpot

A fast object pool for the JVM
http://chrisvest.github.io/stormpot/
Apache License 2.0
348 stars 41 forks source link

Explicit BackgroundProcess #99

Open chrisvest opened 9 years ago

chrisvest commented 9 years ago

Expose an explicit BackgroundProcess, which will be in charge of allocating background allocation threads, and other background threads, such as the time keeper proposed in #92.

The BackgroundProcess would be constructed with a ThreadFactory. Then Config would have a setting for a BackgroundProcess instance, instead of a ThreadFactory. This particular change is breaking backwards compatibility, and thus needs to be done in 3.0!

The BackgroundProcess would be reference counted from the Pool instances, so it knows when to shut down or start up. It will have to be restartable, so it remains usable even if it has previously seen its reference count go to zero.

The BackgroundProcess could use the reference count, and allocation timings, to decide how many allocation threads are needed. This would introduce two-way allocation scaling, where not only can we have fewer allocation threads than there are pools, but we can also have more threads than there are pools, if allocation is particularly expensive.

chrisvest commented 4 years ago

The internal refactorings done as part of #138 will make this easier to do.