On 5/19/16 5:51 PM, Martin Buchholz wrote:
On Thu, May 19, 2016 at 7:29 AM, Peter Levart <peter.lev...@gmail.com> wrote:
So Martin, what do you think?
I studied your code and we are fundamentally in agreement!
... Except for need for periodic cleanup of the cache...
Maybe we should do
CompletableFuture.runAsync(purgeCache,
CompletableFuture.delayedExecutor(1, SECONDS))
as a periodic task while cache is non-empty instead of my strategy of
relying on a weak reference.
Purging a cache on quiescence in the optimal way seems to be a hard problem.
Time to write ObjectPool<T> (as many others have done before us)?
ObjectPool(Supplier<T> factory, Consumer<T> releaser, maxCacheSize,
keepAliveTime)
Except this time we'll do it right! With jdk9 machinery!
personally i agree a non-weak-reference based solution is attractive
here :-)