Threading issue over reference ANY type field within a class

My question is regarding statement assignment from an instance class done by a private ANY field property that references to an external field from a threaded file. To access the external field from the threaded file, it is done through a procedure that will make it possible to complete the reference, this way the ANY field will be considered as the field from the threaded file.

As an example

  1. A class declared in jcParentClass.inc and defined in jcParentClass.clw

Declaration in jcParentClass.inc

jcParentClass          CLASS(),TYPE,Module('jcParentClass.Clw'),LINK('jcParentClass.Clw',_JCLinkMode_),DLL(_JCDllMode_)
! Properties
Component                    ANY,PRIVATE
! Procedures
Init                                  PROCEDURE(), VIRTUAL  !Set the com
SetComponentField       PROCEDURE(*? Component), VIRTUAL  
                             END
  1. Definition in jcParentClass.clw
jcParentClass.Init                          PROCEDURE()

  CODE
  !Some code
!----------------------------------------------------------------------------------------
jcParentClass.SetComponentField PROCEDURE(*? Component)

  CODE
    SELF.Component &= Component
!----------------------------------------------------------------------------------------
  1. Program in Application.clw

Declaration of the file structure

Contact FILE,DRIVER('TOPSPEED'),NAME('Data\Dictionnaire'),PRE(DMLDict),CREATE,BINDABLE,THREAD ! 
RecIDkey KEY(Con:RecID),NOCASE,OPT,PRIMARY ! 
NameKey KEY(Con:Name),DUP,NOCASE,OPT ! 
Record     RECORD,PRE()
RecID         STRING(21) ! 
Name         STRING(55) ! 
               END
            END 

Instance of the ParentClass

jcChildClass               CLASS(jcParentClass)
!Properties and procedures
                                 END

  CODE
    OpeningFiles()
    jcChildClass.Init()
    Main 
  1. Source code of procedure Main in Main.clw file
    calling START(wUpdateContact,25000)
  1. Source code of procedure of wBrowseContact and wUpdateContact in wBrowseContact.clw and wUpdateContact.clw file respectively.

    From the source a call to the file manager global embed area of the Contact file is made, there is a call to Hide:Access:Contact.Init.

Hide:Access:Contact.Init PROCEDURE(File File,ErrorClass EC)

CODE
   jcChildClass.SetComponent(Name)
   PARENT.Init(File,EC)

On the first call to the procedure the Browse is opening but when I call the Browse a second time, deadlock , nothing is appearing. I’ve tried with the debugger to see exactly where the issue is occurring, it is hard to point the bug.

What I know the issue is when we do a reference within a thread, it cannot be recalled the way I did. All the assignment on the first time works perfectly over the referenced field. When the reference is done externally or globally nothing can be assigned because each thread is handling his own set of data, it fulfills its purpose which is exactly that. I must have done something that is not allowed or forgot some kind of declaration or else. I’ved tried with a thread attribute on the jcChildClass, oops, when I left the update procedure the program abort. I’m wondering if I need to add the THREAD attribute on each property of the class. If I do what I need to do exactly.

From the help I did follow this rule on how to reference to an ANY type field.

“When an ANY variable is the destination of a reference assignment statement (destination &= source), the RTL disposes its previous internal data and replaces it with a new object which holds a reference to the source variable. If the source of a reference assignment is NULL, the RTL disposes the previous internal data of the ANY variable from the left side, and then sets the ANY to a NULL reference.”

I understand that we need to execute AnyTypeField reference to NULL before deleting a record from a queue.
Queue.AnyFieldType &= NULL
DELETING(Queue)
It is not the case here.

I’ve watched the Clarion Live webinars regarding thread which they are excellent; the webinar #64 with Paul Blais and Dennis Evans, #313, with Bruce Johnson and Mike Hanson, #533 and #534 with Mike Hanson. It did help me to understand more about thread on how it works and what we can do. I’ve tried to find a replication of this of some sort. I’m trying to find why it does that.

The question what exactly we need to do with an ANY property that reference a field from a threaded file within any thread and making sure there is no leak?

Thank you,
Robert

Seems kinda dangerous. Not sure how well ANY can handle references to threaded data between threads. Maybe it works fine.

Have you considered a class object with Set/Get methods and its own copy of the data? Then you could post an event or something that calls your class method to update the original source in a thread safe way.

1 Like