C++, ProC and threads
Date: Mon, 04 May 1998 23:50:52 -0400
Message-ID: <354E8C9C.DB225054_at_netcom.com>
I am trying to used ProC in a multi thread application using C++. The problem that I am having is that I have created my own C++ class abstractions around ProC. I have a Database class which is used to connect to a database and a Dataset class that is used to select and store data into my C++ structures. The true problem is that I wish to created a multi thread application so this requires that the application has contexts. (create contexts).
To do this, one must define a sql_context. This cannot be done in the header file. It has to be done in the CPP file (implementation file). Because if one uses the command EXEC SQL CONTEXT ALLOCATE :var; the ':var' is a Host Language variable and ProC required that all host language variable in C++ be surround by the command EXEC SQL BEGIN DEFINE and EXEC SQL END DEFINE. I need var to be a member variable of my class Context but this is not possible because class variables are defined in the header and EXEC SQL can not be placed in this file.
I also tried to make this a global sql_context and stored it in a vector. But is did not work because I could not define sql_context in the header. I also tried this in a CPP file as a global to the module:
database.cpp
...
EXEC SQL THEAD YES
EXEC SQL BEGIN DEFINE
sql_context cxt;
EXEC SQL END DEFINE
typedef vector<sql_context> SQL_CONTEXT;
SQL_CONTEXT contextList;
...
// This did not work. I had an undefined cxt and contextList variable
error. The linker could resolve this the extern. I know if it was in a
header this would work.
dataset.cpp
extern sql_context cxt;
SQL_CONTEXT contextList;
Dataset::Dataset()
{
cxt = contextList[1];
EXEC SQL CONTEXT :cxt;
...
}
Help help, how can this be done?
1, Define a sql_context for each Context object . 2. Give access to the Dataset so dataset can used the command EXEC SQL CONTEXT USE :var. Remember var is a host language variable. (By the way, Dataset has a Context object which is defined and passed into the Dataset through the constructor.) Received on Tue May 05 1998 - 05:50:52 CEST