ct-lib: error handling in multi-threaded applications - how ?

ct-lib: error handling in multi-threaded applications - how ?

Post by Otto Li » Wed, 04 Feb 1998 04:00:00





Quote:> hello,

> I am trying to use ct-lib in a muti-threaded application.

> All database access is done via a c++ class

> Currently, the two error handling callbacks (one for open client, one for
> the sql server) are defined as static member functions of the class.

> This is a problem in a multi-threaded application.

Why is this a problem? A static member function does not imply that it is
not thread safe. Just make sure that any calls you make within the error
handler are thread safe, and don't use globals/static variables in the
method.

Or is it that you want access back to the C++ object instance which
"caused" the error? If so, I would recommend using the CS_USERDATA
property to store the "this" pointer into the command and/or connection
structure. The error handler can then get the pointer and invoke class
methods (or whatever) with it. Make sure to pay attention to the object
lifecycle so that stale pointers are never stored via CS_USERDATA.

Otto

--
Otto Lind                  Softwire Corporation (North office)


 
 
 

ct-lib: error handling in multi-threaded applications - how ?

Post by Michael Zarlen » Thu, 05 Feb 1998 04:00:00


: I am trying to use ct-lib in a muti-threaded application.

: All database access is done via a c++ class

: Currently, the two error handling callbacks (one for open client, one for
: the sql server) are defined as static member functions of the class.

: This is a problem in a multi-threaded application.

What, specifically, is the problem?

--
-- Mike Zarlenga

   "The American people are tired of liars and people who pretend
    to be something they're not."
                Hillary Clinton, 1992 60 Minutes interview