Subject | Re: [IBO] Multi-threaded ISAPI hangs |
---|---|
Author | Gary Benade |
Post date | 2004-06-11T06:39:39Z |
From the website online faq:
Is IBO is thread-safe? Do I need a new connection for each thread, or just
new transaction components?
You need not only a connection for each thread but it is also a good idea to
have a TIB_Session for each thread.
When the connection, transaction and dataset components are created, make
the session their owner.
This isolates each thread from other thread contexts.
If you do this then IBO is fully thread-safe.
so, something like this:
IB_Session1 = new
TIB_Session( NULL);
IBODatabase1 = new
TIBODatabase( IB_Session1);
IBODatabase1->Server =
"localhost";
IBODatabase1->Path =
"test.gdb";
IBODatabase1->Protocol =
cpTCP_IP;
IBODatabase1->Username =
"SYSDBA";
IBODatabase1->Password =
"masterkey";
IBODatabase1->LockWait =
false;
IBODatabase1->RecVersion =
true;
IBODatabase1->Isolation =
tiCommitted;
IBODatabase1->AutoCommit =
true;
IBODatabase1->SQLDialect = 3;
IBODatabase1->Connected =
true;
IBODatabase1->StartTransaction();
Query1 = new TIBOQuery(
IB_Session1);
Query1->IB_Connection =
IBODatabase1;
Query1->SQL->Add("select *
from test");
you get the idea
Regards
Gary
Is IBO is thread-safe? Do I need a new connection for each thread, or just
new transaction components?
You need not only a connection for each thread but it is also a good idea to
have a TIB_Session for each thread.
When the connection, transaction and dataset components are created, make
the session their owner.
This isolates each thread from other thread contexts.
If you do this then IBO is fully thread-safe.
so, something like this:
IB_Session1 = new
TIB_Session( NULL);
IBODatabase1 = new
TIBODatabase( IB_Session1);
IBODatabase1->Server =
"localhost";
IBODatabase1->Path =
"test.gdb";
IBODatabase1->Protocol =
cpTCP_IP;
IBODatabase1->Username =
"SYSDBA";
IBODatabase1->Password =
"masterkey";
IBODatabase1->LockWait =
false;
IBODatabase1->RecVersion =
true;
IBODatabase1->Isolation =
tiCommitted;
IBODatabase1->AutoCommit =
true;
IBODatabase1->SQLDialect = 3;
IBODatabase1->Connected =
true;
IBODatabase1->StartTransaction();
Query1 = new TIBOQuery(
IB_Session1);
Query1->IB_Connection =
IBODatabase1;
Query1->SQL->Add("select *
from test");
you get the idea
Regards
Gary