SQLitening Support Forum

SQLitening Support => You've got Questions? We've got Answers! => Topic started by: Bern Ertl on May 14, 2009, 01:39:37 pm

Title: SQLiteningProcs and THREADED scope
Post by: Bern Ertl on May 14, 2009, 01:39:37 pm
If I develop a set of functions to implement a new data structure (http://www.powerbasic.com/support/pbforums/showpost.php?p=315333&postcount=13) inside an SQLiteningProcs DLL, would setting the scope for the underlying base data as THREADED ensure that each connection to the database had it's own persistent copy of the data (persistent through numerous calls to various functions in the DLL), or is each function call to the SQLiteningProcs DLL being handled in a unique thread? Or are all function calls to the SQLiteningProcs DLL being handled in a single thread?

Title: Re: SQLiteningProcs and THREADED scope
Post by: Fred Meier on May 14, 2009, 05:55:57 pm
Each connection at the server runs as a separate single thread.  This
means that all the commands as well as your SQLiteningProcs run in the
same unique thread for that connection.  So if two clients are connected
there are two threads running. 

Yes, using THREADED shared variables(globals) rather than GLOBAL ones
would seem to be the safe way to share date among several functions
within a SQLiteningProc running in a thread. 

I have not personally tested this concept so let us know how it works. 
Title: Re: SQLiteningProcs and THREADED scope
Post by: Bern Ertl on May 14, 2009, 07:14:38 pm
Excellent.  I did a simple test and it appears to be working as described.  Each instance of the client calling the proc has it's own persistent copy of the data.