10.12.2012 Views

Oracle C++ Call Interface Programmer's Guide

Oracle C++ Call Interface Programmer's Guide

Oracle C++ Call Interface Programmer's Guide

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Advanced Relational Techniques<br />

Application-Provided Serialization In cases where there are multiple threads operating<br />

on objects derived from an OCCI environment, you can chose to manage<br />

serialization. The first step is to pass a value of THREADED_UNMUTEXED for the<br />

createEnvironment mode. In this case the application must mutual exclusively<br />

lock OCCI calls made on objects derived from the same OCCI environment. This<br />

has the advantage that the mutex scheme can be optimized based on the application<br />

design to gain greater concurrency.<br />

When an OCCI environment is created in this mode, OCCI recognizes that the<br />

application is running in a shared server environment, but that OCCI need not<br />

acquire its internal mutexes. OCCI assumes that all calls to methods of objects<br />

derived from that OCCI environment are serialized by the application. You can<br />

achieve this two different ways:<br />

■ Each thread has its own environment. That is, the environment and all objects<br />

derived from it (connections, connection pools, statements, result sets, and so<br />

on) are not shared across threads. In this case your application need not apply<br />

any mutexes.<br />

■ If the application shares an OCCI environment or any object derived from the<br />

environment across threads, then it must serialize access to those objects (by<br />

using a mutex, and so on) such that only one thread is calling an OCCI method<br />

on any of those objects.<br />

Basically, in both cases, no mutexes are acquired by OCCI. You must ensure that<br />

only one OCCI call is in process on any object derived from the OCCI environment<br />

at any given time when THREADED_UNMUTEXED is used.<br />

Note:<br />

2-26 <strong>Oracle</strong> <strong>C++</strong> <strong>Call</strong> <strong>Interface</strong> Programmer’s <strong>Guide</strong><br />

■ OCCI is optimized to reuse handles as much as possible. Since<br />

each environment has its own heap, multiple environments<br />

result in increased consumption of memory. Having multiple<br />

environments may imply duplicating work with regard to<br />

connections, connection pools, statements, and result set<br />

objects. This will result in further memory consumption.<br />

■ Having multiple connections to the server results in more<br />

resource consumptions on the server and network. Having<br />

multiple environments would normally entail more<br />

connections.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!