Alaska Software Inc. - Re: DataObject xbase 2.0 726
Username: Password:
AuthorTopic: Re: DataObject xbase 2.0 726
Andreas Gehrs-Pahl

View the complete thread for this message in:

Re: DataObject xbase 2.0 726
on Thu, 13 Oct 2016 16:02:25 -0400
Raffaele,

>I use DataObject in a large multithreaded applications ( webserver )
>I use a Dataobject for every session and every thread

DataObjects are not "thread-safe" in the way you are apparently trying to 
use them. If a DataObject is accessed from more than one thread at the same 
time, the application will hang, because each thread is waiting for the 
other one(s) to release the object.

If you want to use DataObjects the way your code seems to use them, you need 
to implement some sort of thread-safe wrapper for them yourself, for example 
using a custom class with a Synch(ed) Access/Assign (Class) Method.

Example (pseudo) code:

Class AppInfo
   Exported:
   Class Var oInfo

   Class Method Init

   Sync Access Assign Class Method oInfo
EndClass

Class Method AppInfo:Init()
   ::oInfo := DataObject():New()
return (Self)

Class Method AppInfo:oInfo(oInfo)
   if PCount() == 1
      ::oInfo := oInfo
   endif
return (::oInfo)

And then use it like this:

Function InitSession()
LOCAL oApp := AppInfo():New()
   oApp:oInfo:session   := cIdSession
   oApp:oInfo:user      := "XXX"
   oApp:oInfo:lingua    := 1
   oApp:oInfo:collation := SetCollation()
   oApp:oInfo:codepage  := 0
   oApp:oInfo:userPath  := ""
   oApp:oInfo:userFiles := ""
   oApp:oInfo:usage     := 0
   oApp:oInfo:Started   := MilliSeconds()
   oApp:oInfo:forms     := {}
return (oApp)

Function Update()
LOCAL oApp := Xsession()  retrieve session information
   oApp:oInfo:NewMember := "Some Value"
[...]

That should basically work and the application shouldn't hang anymore.

Hope that helps,

Andreas

Andreas Gehrs-Pahl
Absolute Software, LLC

phone: (989) 723-9927
email: Andreas@AbsoluteSoftwareLLC.com
web:   http://www.AbsoluteSoftwareLLC.com
[F]:   https://www.facebook.com/AbsoluteSoftwareLLC