Solved

HERE!! :-)   Thread safe abstraction layer

Posted on 2002-07-08
2
258 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
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

Swamped with email signature updates?

Have you been given a load of changes to make to your users’ email signatures? Having to manually implement multiple signatures for every department? Let Exclaimer save you from being swamped with email signature updates!

Question has a verified solution.

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

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…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.

943 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now