Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

HERE!! :-)   Thread safe abstraction layer

Posted on 2002-07-08
2
Medium Priority
?
266 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 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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…
An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.

610 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