[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [cp-patches] FYI: Implemented an ObjectPool: I think, the synchroniz
From: |
Roman Kennke |
Subject: |
Re: [cp-patches] FYI: Implemented an ObjectPool: I think, the synchronization is necessary. |
Date: |
Fri, 01 Jul 2005 14:49:18 +0200 |
Am Freitag, den 01.07.2005, 14:35 +0200 schrieb Meskauskas Audrius:
> Roman Kennke wrote:
>
> >I implemented and added an ObjectPool class.
> >
> I suggest to synchronize (pool) { before doing anything with it }.
Yeah, I added that. I will commit this ASAP.
> Also, the pool may cause memory leak if the returnObject is called more
> often than borrowObject.
I also fixed this. Returned object are only added to the pool if the
pool is not on its limit. ATM I have set the limit to 64 instances per
type, this may or may not be good. Anyway, I am going to do some
benchmarking first before 'optimizing' anything.
> Despite one instance of the pool seems sufficient, I suggest to leave
> its constructor public. The application with many parallel threads may
> prefer to have an array of pools, every time selecting a random member
> to operate. This helps against the loss of performance due necessity for
> other threads to wait while one of them is getting/returning an object.
That is right. I will consider this. Note that the pool is not open for
use in applications anyway.
/Roman