` Printed Icetips Article

Icetips Article



Par2: Clarion Threads: Relation manager
2002-12-29 -- Owen Brunker
 
I've made all the necessary modifications to the ABC classes to test my idea
and so far so good.  One interesting discovery though is the fact that the
Relation Manager object is not thread safe.  Relation Manager uses a queue
of references to manage relationship links between other Relation manager
objects.  Each queue record also contains a reference to an instance of the
buffered fields class to manage the fields used to form the relationship
link. It is the implementation of the buffered fields class that is not
thread safe.

At the heart of the BufferedFieldClass is a queue containing three fields.
BufferedPairsQueue.Left, BufferedPairsQueue.Right and
BufferedPairsQueue.Buffer.  It is field BufferedPairsQueue.Buffer that is
the problem.  When a record update form is called, the Window Manager class
calls RelationManager.Save from its PrimeUpdate method.
RelationManager.Save loops through the Relation manager's queue of
relationship links and calls the queue record's instance of
BufferedPairsClass.AssignLeftToBuffer  causing the current file record's
link fields to be saved.  If a second instance of the record update form is
opened on another thread, the saved link fields for the previous thread is
over written.  When you go back to the first instance of the record update
form, change the contents of one field and then save the record, you will
witness all the child records having the cascade on update attribute will
attach themselves to the record contained in the second instance of the
record update form.  I am currently looking at making the RelationManager's
implementation of the BufferedPairsClass thread safe so I dont have this
problem.



Printed November 23, 2024, 2:12 am
This article has been viewed/printed 35232 times.