![]() | ![]() |
Home |
|
|
Sybase dbQueue Reference Guide |
|
| Chapter 1: Using the dbQueue Objects Library |
|
| Multi-Threaded Applications |
The dbQueue objects library protects multi-threaded applications from race conditions and deadlocks while using the library. However, applications must also obey certain conventions to avoid conflicts between threads.
The dbQueue objects library single-threads all operations on objects allocated from a DbqEnv instance. Only one thread is active at the same time within the DbqEnv scope. If two threads try to access objects in the same scope, the first thread executes while the second thread waits. If objects are in different scopes, both threads may proceed.
In general, multi-threaded applications should allocate a DbqEnv instance for each thread to ensure proper isolation between threads. The one-thread-per-instance locking mechanism ensures multiple threads will not deadlock or encounter race conditions when accessing shared objects.
dbQueue objects library single-threads other operations, such as database access. Therefore, long-running administrative operations, such as installing a catalog, may delay other threads access to the library. If performance is a consideration, users can perform these operations as separate processes.
dbQueue objects support both native and Open Server threads, however, you cannot use both in the same process.
Link your dbQueue applications with one of these libraries:
The C++ sample programs contain makefiles that illustrate linking logic for the native threads library.
WARNING! Open Server applications must call srv_init() before invoking dbQueue objects routines. Otherwise, an Open Server error occurs.
|
|