Hi Martin - I just got a chance to look at your code. First the good news - we are both putting forward the same solution (in terms of the important two locks in place when writing).
Your code has separated out these concerns into: -cache: ConcurrentHashMap<K,V> -locks: HashMap<K,ReentrantLock> Your points are all valid (with respect to no special map entry, less objects, less locking during reads). I will need to revise your implementation a bit in order to handle WeakReferences. I was a bit happier doing that by improving ObjectCacheEntry over time - in much the same way you did things for WeakHashSet.Entry. I confess most of my happiness is just in terms of code style - I like being able to test ObjectCacheEntry in isolation. But yes, both solutions work with respect to concurrency ... we only differ in style. Cory came up with a solution similar to yours a couple weeks ago and I rejected it as it was possible for client code to mess things up. But once again that is a style difference. So to proceed: - I will grab your implementation into the code base (using Java 1.4) - We will stress test both and see if there is a difference in terms of memory use / performance / etc.. If the performance hit of keeping a read lock around on an already created object is too annoying I am quite sure we can code around it. Cheers, Jody Martin Desruisseaux wrote: > Martin Desruisseaux a écrit : >> So there is my proposal: I will commit a ObjectCache2 class (without >> any ObjectCacheEntry class) so you can see my point. It will use the >> modified workflow that I tried to explain in my previous email. > > There is the proposal (not commited because it use Java 5 features). > > * No ObjectCacheEntry. > > * Less objects keep around (no Lock objects retained after > the cached object creation). > > * Less locking than the original DefaultObjectCache > during read operation. > > I have not tested; it is just in order to show my point. > > Your previous emails suggest that you think that I didn't understood > your goals. I believe that I understood your goals from the begining, > but that I have been unable to explain why I believe that a > ReadWriteLock in ObjectCacheEntry is an unneeded overhead for your > goals. Please read again my "modified workflow" in my yesterday email, > and I would appreciate if you can point me a flaw in this workflow > regarding your goals. > > Martin ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ Geotools-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/geotools-devel
