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 />

processors, and on single processor systems where overlap can occur between<br />

slower operations and faster operations.<br />

Thread Safety and Three-Tier Architectures<br />

In addition to client/server applications, where the client can be a shared server<br />

program, a typical use of shared server applications is in three-tier (also called<br />

client-agent-server) architectures. In this architecture, the client is concerned only<br />

with presentation services. The agent (or application server) processes the<br />

application logic for the client application. Typically, this relationship is a<br />

many-to-one relationship, with multiple clients sharing the same application server.<br />

The server tier in the three-tier architecture is an <strong>Oracle</strong> database server. The<br />

applications server (agent) is very well suited to being a shared server application<br />

server, with each thread serving a client application. In an <strong>Oracle</strong> environment, this<br />

middle-tier application server is an OCCI or precompiler program.<br />

Implementing Thread Safety<br />

In order to take advantage of thread safety by using OCCI, an application must be<br />

running on a thread-safe platform. Then the application must inform OCCI that the<br />

application is running in shared server mode by specifying THREADED_MUTEXED or<br />

THREADED_UNMUTEXED for the mode parameter of the createEnvironment<br />

method. For example, to turn on mutual exclusivity locking, issue the following<br />

statement:<br />

Environment *env = Environment::createEnvironment(Environment::THREADED_<br />

MUTEXED);<br />

Note that once createEnvironment is called with THREADED_MUTEXED or<br />

THREADED_UNMUTEXED, all subsequent calls to the createEnvironment method<br />

must also be made with THREADED_MUTEXED or THREADED_UNMUTEXED modes.<br />

If a shared server application is running on a thread-safe platform, then the OCCI<br />

library will manage mutexes for the application on a for each-OCCI-environment<br />

basis. However, you can override this feature and have your application maintain<br />

its own mutex scheme. This is done by specifying a mode value of THREADED_<br />

UNMUTEXED to the createEnvironment method.<br />

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

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

Saved successfully!

Ooh no, something went wrong!