Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2008-12

TAVLTree(avl_tree.pp) and "XML DOM" (dom.pp) thread safety issues

5 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Inoussa OUEDRAOGO

Hi,

A discussion started a month or two ago about the thread safety issue concerning XML DOM, issue due to avl_tree.pp implementation.

There were 3 propositions :

1 - Inoussa OUEDRAOGO :
Another proposition is to introduce a base avl class say TBaseAVLTree that defines two abstract virtual methods "NewNode()" and "FreeNode()" and then define :
- TAVLTree : that _do not_ use a node mem manager, then thread safe.
- TAVLManagedTree that uses a node mem manager provided in the constructor.
The developer using this one is _aware_ of the thread safety issue and can
then provide a thread safe node mem manager for an instance exposed to more than one thread while using the default not thread safe node mem manager for a thread local instance

2 - Marc Weustink :
I'm pro having a manged and an unmanaged avltree. One (big) disadvantage
of the current implementation (with a shared node manager for all trees)
is that you cannot add custom derived treenodes since they will be released in the pool too.
Mattias Gärtner :
I think too, that we need a fast, lightweight tree and a slower, but customizable tree. Something like TFPList and TList. One without virtual
methods and one with virtual methods and definable node class

3 - Sergei Gorelkin : I would like to vote for removing avl_tree dependency from the DOM altogether

I would like to bring back the discussion hoping that this time a definitive solution will be adopted.

No matter what solution will be choosed, a thread-safe implementation of AVL tree is a must, IMHO.

PS : the discussions are at

Best regards.

Inoussa O.

Reply by email

Mattias Gaertner
to Inoussa OUEDRAOGO
Show quoted text 37 lines
Hi, A discussion started a month or two ago about the thread safety issue concerning XML DOM, issue due to avl_tree.pp implementation. There were 3 propositions : 1 - Inoussa OUEDRAOGO : Another proposition is to introduce a base avl class say TBaseAVLTree that defines two abstract virtual methods "NewNode()" and "FreeNode()" and then define : - TAVLTree : that _do not_ use a node mem manager, then thread safe. - TAVLManagedTree that uses a node mem manager provided in the constructor. The developer using this one is _aware_ of the thread safety issue and can then provide a thread safe node mem manager for an instance exposed to more than one thread while using the default not thread safe node mem manager for a thread local instance 2 - Marc Weustink : I'm pro having a manged and an unmanaged avltree. One (big) disadvantage of the current implementation (with a shared node manager for all trees) is that you cannot add custom derived treenodes since they will be released in the pool too. Mattias Gärtner : I think too, that we need a fast, lightweight tree and a slower, but customizable tree. Something like TFPList and TList. One without virtual methods and one with virtual methods and definable node class [...] No matter what solution will be choosed, a thread-safe implementation of AVL tree is a must, IMHO.

Yes.
1+2 sounds compatible.

Will you provide a patch?

Mattias

Reply by email

Inoussa OUEDRAOGO
to Inoussa OUEDRAOGO

2008/12/19 Inoussa OUEDRAOGO :

Show quoted text 9 lines
>> No matter what solution will be choosed, a thread-safe implementation >> of AVL tree is a must, IMHO. > > Yes. > 1+2 sounds compatible. > > Will you provide a patch? Yes :-)

The patch and a simple fpc-unit test.

Best regards.

Inoussa O.

Reply by email