Cursors and Multiple threads

Srinivas Yalamarti syalamar at fiberlink.com
Tue Jun 15 18:37:10 CDT 2004


Hi

Ours is a multi-threaded application.  I know that valentina cache can be 
accessed
only by one thread at a time.

If the following happens in that sequence, is the following OK

        Thread A
                VDK_Cursor* pCursorThreadA = NULL;

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

                ...OS switch thread context...

        Thread B
                VDK_Cursor* pCursorThreadB = NULL;

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

                ...OS switch thread context...

        ThreadA
                --- NO MORE LOCKING DONE HERE ---
                pCursorThreadA ->GetRecordCount()
                // And also some code that uses pCursorThreadA 

                ...OS switch thread context...

        ThreadB
                --- NO MORE LOCKING DONE HERE ---
                pCursorThreadB ->GetRecordCount()
                // And also some code that uses pCursorThreadB 

                ...OS switch thread context...

        ThreadA
                --- NO MORE LOCKING DONE HERE ---
                ForgetObject(pCursorThreadA );

                ...OS switch thread context...

        ThreadB
                --- NO MORE LOCKING DONE HERE ---
                ForgetObject(pCursorThreadB );

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?

Regards,
Srini Y


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