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 and defined in jcParentClass.clw

Declaration in

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  
  1. Definition in jcParentClass.clw
jcParentClass.Init                          PROCEDURE()

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

    SELF.Component &= Component
  1. Program in Application.clw

Declaration of the file structure

NameKey KEY(Con:Name),DUP,NOCASE,OPT ! 
Record     RECORD,PRE()
RecID         STRING(21) ! 
Name         STRING(55) ! 

Instance of the ParentClass

jcChildClass               CLASS(jcParentClass)
!Properties and procedures

  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)


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
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,

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