Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
DB Interface Module User's Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

11.3 Sharing Objects of the DB Interface Module Among Threads

Applications that share objects of the DB Interface Module across threads can use an object's internal mutex to control access. This is accomplished through two member functions:

The acquire() function locks the internal mutex, while the release() function unlocks it. Most objects of the DB Interface Module provide these functions, as noted in the Reference Guide. They are available even in single-threaded environments, where they are no-ops. This maintains portability of applications across both single-threaded and multithreaded environments.

Please note that acquire() and release() must be called in pairs, or deadlock can occur. Deadlock results when an application attempts to acquire a mutex that is not released, frequently because an exception was thrown. To prevent deadlocks, you can use a simple technique called a guard class. In C++, the guard class constructor acquires the mutex at initialization, and the destructor releases it upon destruction. How you use a guard class depends upon whether or not your compiler supports templates. Refer to Section 11.6, Section 11.7, and Section 11.8 for further details.



Previous fileTop of DocumentContentsNo linkNext file

Copyright © Rogue Wave Software, Inc. All Rights Reserved.

The Rogue Wave name and logo, and SourcePro, are registered trademarks of Rogue Wave Software. All other trademarks are the property of their respective owners.
Provide feedback to Rogue Wave about its documentation.