Solved

HERE!! :-)   Thread safe abstraction layer

Posted on 2002-07-08
2
262 Views
Last Modified: 2010-04-15
I've got to develop a database abstraction layer to be used with Oracle and PostgreSQL. It'll have to be fast, so I'm using a bunch of ifdefs and letting the compiler do the work. (so, only one will be compiled).

ODBC is not an option because we need native data handling.

The problem is that this abstraction layer must be fully transparent (IE, the program will call just one function without taking care of handle casts) AND thread safe (we'll open more than one connection -- will be using posix threads).

There's more than one function, so the easiest solution would be placing a global variable for the connection handle/result, but this would break the thread safety. Another option is to give/get the handle variables from/to the functions, but this would break the "full transparency" of the abstraction layer, which is (unfortunatelly) essential to the project.

I'd like to hear you suggestions. If necessary, I can post some of the code here or email it to you.

Thanks a lot.
0
Comment
Question by:suguinha
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 1

Accepted Solution

by:
andymurd earned 500 total points
ID: 7221979
You could try using thread local storage to provide a "global" variable per thread. Look for pthread_key_create() on *nix and TlsAlloc() on win32.

Its a pretty icky solution though. I'd prefer to specify an environment, connection or cursor handle to each function.
0
 

Author Comment

by:suguinha
ID: 8049647
Thanks, we've switched to multiple processes/IPC model.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question