Cursors and Multiple threads

Srinivas Yalamarti syalamar at fiberlink.com
Sun Jun 27 11:59:43 CDT 2004


Hi Ruslan,

I wrote:

> In other words, can we get 'cursors' in a thread-safe fashion by locking
> the db, and then 'use' the cursors without the
> locking mechanism?

You wrote:

>>Again no.

>>Because very very often Valentina uses so called "indirect cursors".

>>Such cursor read values of the next record from original tables!
>>I.e. It touch global single cache.

So, what does all this mean?

Does it mean, in a multi-threaded application, on a stand-alone machine 
(no valentina server used), 
only one thread can access a Valentina DB, one at a time?  All access to 
any Valentina Databases
used by that application has to be synchronized by the application?
Does it mean that the cursors can be used only the following way, and NOT 
the way I mentioned in my EARLIER posting?

        Thread A
        ========

                VDK_Cursor* pCursorThreadA = NULL;

                LOCKDB(ONE_AND_ONLY_SYNC_OBJECT);
                        pCursorThreadA  = m_pDatabase->SqlSelect(strSQLA, 
kServer, kReadOnly);

                        pCursorThreadA ->GetRecordCount();

                        // And also some code that uses pCursorThreadA 

                        ForgetObject(pCursorThreadA );
                UNLOCKDB(ONE_AND_ONLY_SYNC_OBJECT);

        Thread B
        =========
                VDK_Cursor* pCursorThreadB = NULL;

                LOCKDB(ONE_AND_ONLY_SYNC_OBJECT);
                        pCursorThreadB  = m_pDatabase->SqlSelect(strSQLB, 
kServer, kReadOnly);

                        pCursorThreadB ->GetRecordCount();

                        // And also some code that uses pCursorThreadB 

                        ForgetObject(pCursorThreadB );
                UNLOCKDB(ONE_AND_ONLY_SYNC_OBJECT);



>From Valentina Kernel Documentation:

"Cursors are good choices for implementing multi-user application. Each 
Cursor can be
executed in separate thread of your application and represent one user."

>From VSDK Reference Documentation:

"Important: A Cursor has its own copy of fields, so it is independent from 
BaseObjects and
from other Cursors. This make Cursors very useful for multi-thread 
applications."

I am confused with what is being specified in the documentation.

Thank you for all your input.

Regards,
SY

The information transmitted is intended only for the person or entity to 
which it is addressed and may contain confidential and/or privileged 
material.  Any review, retransmission, dissemination or other use of, or 
taking of any action in reliance upon, this information by persons or 
entities other than the intended recipient is prohibited.   If you 
received this in error, please contact the sender and delete the material 
from any computer.


More information about the Valentina mailing list