From: Michael H. <mic...@el...> - 2005-09-22 07:59:43
|
Hi, yesterday I spent a couple of hours with looking into recursive locking. It's not as easy as it looks at first :-( First let me propose a small refactoring: Right now MetadataCollection, Relation and Procedure all inherit from MetadataItem. Why don't we create a new class MetadataItemWithChildren, which will be base class for those three. This would move some of the common code out of MetadataCollection, making the instantiated templated code smaller. It would also be the one place to override lockSubject() and unlockSubject(), which I had to do in all three classes otherwise. Or is there anything speaking against this? The more difficult thing is the management of the update lock counter for children. There is code in MetadataCollection to create new children, but they are always created with the lock counter set to 0, even if the parent has a higher lock count. My preference would be to make the initial lock counter value a parameter to the constructor, but that would need changes in all of the classes. Another way I see is to create protected methods getLockCounter() and setLockCounter(), but that seems really ugly, and opens up a lot of possibilities for trouble and bugs. Any comments, ideas, please? Thanks -- Michael Hieke |