Accessing an databases in concurrent threads

Ruslan Zasukhin sunshine at public.kherson.ua
Sun Mar 20 19:13:34 CST 2005


On 3/20/05 3:37 PM, "jda" <jda at his.com> wrote:

> Hi Ruslan and everyone,
> 
> I am serving Valentina databases using RB. The sockets are threaded,
> so my app can respond asynchronously.
> 
> I keep an array of folderItems  of the databases that are open (I
> doing read only), and only close a database when all queries to it
> are complete (i.e. the array is empty)
> 
> The problem I'm having is that if a database is in use and another
> request comes in, I have to get acces to that database to do a query
> (again, read only, so no locked cursor problems). However, if I try
> to open a databas that is in use of course an exception is generated.
> I wonder what the best solution is?
> 
> I have thought of:
> 
> 1. polling any open socket threads and setting "myDatabase" of the
> new thread to the "myDatabase" of a thread using the same folderItem
> 
> 2. using a try/catch block when trying to open the database, and if
> it's a "file is open" error trying again (for,say, 60 seconds) until
> I either open the database or it times out.
> 
> Any thoughts/suggestions?

Each thread should keep own cursor.

You need one semaphore for Valentina

Each thread must concurrent for this semaphore/mutex

-- 
Best regards,
Ruslan Zasukhin      [ I feel the need...the need for speed ]
-------------------------------------------------------------
e-mail: ruslan at paradigmasoft.com
web: http://www.paradigmasoft.com

To subscribe to the Valentina mail list go to:
http://lists.macserve.net/mailman/listinfo/valentina
-------------------------------------------------------------




More information about the Valentina-beta mailing list