Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 5 of 5 total
Thread Using threads
Mon, Jul 4 2016 6:33 AMPermanent Link

Ronald

Hi,

I want to start using the Elevate Web Builder Modules. In the manual you warn about thread-safe programming in these modules. I have read about thread safe programming and I understand that I shoud use threads. In your demo application "datasetmodule" I do not see any use of threads. Can you give me a general rule of thumb advice on when to use threads in a module?  

Greetings,
Ronald
Mon, Jul 4 2016 3:50 PMPermanent Link

Emin

Hi Ronald

<In your demo application "datasetmodule" I do not see any use of threads>

Because the thread is managed (created/destroyed/pooled) within the EWB http server.
TExampleDataSetModule is run within a context of this thread. So your code must be thread safe when using shared objects like database connections etc.

<Can you give me a general rule of thumb advice on when to use threads in a module? >
Unless you are going to start an asynchronous job etc. you don't need to create any additional threads in a module.

Regards
Emin Borbor
Tue, Jul 5 2016 7:35 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Ronald,

Everything that Emin said is 100% correct. Smile

Tim Young
Elevate Software
www.elevatesoft.com
Thu, Jul 7 2016 10:03 AMPermanent Link

Ronald

Thanks Emin and Tim,

But I still should not use global variables and I should take extra care when reading and writing to a .txt file on disk for example, I presume?

Ronald
Thu, Jul 7 2016 10:09 AMPermanent Link

Raul

Team Elevate Team Elevate

On 7/7/2016 10:03 AM, Ronald wrote:
> But I still should not use global variables and I should take extra care when reading and writing to a .txt file on disk for example, I presume?

In terms of accessing database (EDB/DBISAM) then you need to follow
thread safe instructions for each.

In terms of things like simple global variables (not EDB/DBISAM objects
like sessions, tables, queries) if they are set one (say on startup) and
then various threads simply read them then you're ok.

If however the global variables are read and updated by one or more
thread during runtime then you definitely need to use some sort of
locking/syncronization method for access.

Similar rules apply to file reading/writing

Raul
Image