Board index » delphi » IBX and thread issues - TeamB

IBX and thread issues - TeamB

Hi

I just want to make something clear or make sure that I understand it
correctly.
In our main app we create a TIBDatabase component and establishes a
connection.
We then pass the handle of this connection between our dll's so that only
one connection is used.
The way we use this is as follows:
We have a custom datamodule with a tibdatabase on it .In the dll we create
the dm and assign the created connection's handle to it.
This works perfectly.

Now for threads. I understand the issues regarding threads. Unique
connection and tcp/ip.
What I want to know what is the correct way to use it:
1) Create a TIBDatabase component,establish a unique connection and the pass
it to multiple instances of the datamodule
    throughout the thread.

OR

2)Create one datamodule and establish an unique connection with the
tibdatabase component on it and use
   only this one instance of the datamodule throughout the thread.

The way I understand it is that I must create one unique datamodule with one
unique connection and use it throughout the thread.

TIA

--
Ruaan Barnard
ru...@ccs-software.co.za
www.ccs-software.co.za

 

Re:IBX and thread issues - TeamB


Quote
Ruaan Barnard wrote:

> I just want to make something clear or make sure that I understand it
> correctly.
> In our main app we create a TIBDatabase component and establishes a
> connection.
> We then pass the handle of this connection between our dll's so that only
> one connection is used.

        That's fine.

Quote
> The way we use this is as follows:
> We have a custom datamodule with a tibdatabase on it .In the dll we create
> the dm and assign the created connection's handle to it.
> This works perfectly.

        ...as it should.

Quote
> Now for threads. I understand the issues regarding threads. Unique
> connection and tcp/ip.
> What I want to know what is the correct way to use it:
> 1) Create a TIBDatabase component,establish a unique connection and the pass
> it to multiple instances of the datamodule
>     throughout the thread.

        As long as the connection is being used by only one thread at a time,
you can share it between as many DMs as you want.  For example, if you
create 27 DMs in a single thread and use them concurrently within the
thread, that's fine.  If you create 27 DMs, each in their own thread,
then they'll all need their own connection to IB.

Quote
> The way I understand it is that I must create one unique datamodule with one
> unique connection and use it throughout the thread.

        No, you can have many DMs in the thread using the same IB connection.
I do this in my DataSnap servers.

        -Craig

--
 Craig Stuntz (TeamB) Vertex Systems Corp. Columbus, OH
We're hiring: http://www.vertexsoftware.com/careerops.htm#sd
     Delphi/InterBase WebLog: http://delphi.weblogs.com

Re:IBX and thread issues - TeamB


Hi Craig

Thanks for clearing things up for me and thanks for all the work you put
into this group.

Regards

Ruaan
"Craig Stuntz (TeamB)" <cstuntz@no_spam.vertexsoftware.com> wrote in message
news:3C03CE64.A70B2CAF@no_spam.vertexsoftware.com...

Quote

> Ruaan Barnard wrote:

> > I just want to make something clear or make sure that I understand it
> > correctly.
> > In our main app we create a TIBDatabase component and establishes a
> > connection.
> > We then pass the handle of this connection between our dll's so that
only
> > one connection is used.

> That's fine.

> > The way we use this is as follows:
> > We have a custom datamodule with a tibdatabase on it .In the dll we
create
> > the dm and assign the created connection's handle to it.
> > This works perfectly.

> ...as it should.

> > Now for threads. I understand the issues regarding threads. Unique
> > connection and tcp/ip.
> > What I want to know what is the correct way to use it:
> > 1) Create a TIBDatabase component,establish a unique connection and the
pass
> > it to multiple instances of the datamodule
> >     throughout the thread.

> As long as the connection is being used by only one thread at a time,
> you can share it between as many DMs as you want.  For example, if you
> create 27 DMs in a single thread and use them concurrently within the
> thread, that's fine.  If you create 27 DMs, each in their own thread,
> then they'll all need their own connection to IB.

> > The way I understand it is that I must create one unique datamodule with
one
> > unique connection and use it throughout the thread.

> No, you can have many DMs in the thread using the same IB connection.
> I do this in my DataSnap servers.

> -Craig

> --
>  Craig Stuntz (TeamB) Vertex Systems Corp. Columbus, OH
> We're hiring: http://www.vertexsoftware.com/careerops.htm#sd
>      Delphi/InterBase WebLog: http://delphi.weblogs.com

Re:IBX and thread issues - TeamB


Just so I am  clear on this. Does this mean that - if I am creating an ISAPI
application using an Internet Express webmodule that contains an
IBDatatabase component, an IBTransaction and an IBQuery component, I do not
have to do anything more (with respect to these IBX components) to ensure
thread safety since separate web module instances are generated for each
thread at runtime?

I have had problems using IBX components in ISAPI dlls in the past. At the
time I suspected that the problems may have something to do with issues of
thread safety. Unfortunately, I did not then have the the time to track down
the source of the problem and simply let it go. Since performance was not a
real issue, I converted my apps to standard win-cgi apps and they worked
fine. However, I would like to revisit the issue now. If thread safety
wasn't the problem, at least I know to look elsewhere for it.

"Craig Stuntz (TeamB)" <cstuntz@no_spam.vertexsoftware.com> wrote in message
news:3C03CE64.A70B2CAF@no_spam.vertexsoftware.com...

Quote

> Ruaan Barnard wrote:

> > I just want to make something clear or make sure that I understand it
> > correctly.
> > In our main app we create a TIBDatabase component and establishes a
> > connection.
> > We then pass the handle of this connection between our dll's so that
only
> > one connection is used.

> That's fine.

> > The way we use this is as follows:
> > We have a custom datamodule with a tibdatabase on it .In the dll we
create
> > the dm and assign the created connection's handle to it.
> > This works perfectly.

> ...as it should.

> > Now for threads. I understand the issues regarding threads. Unique
> > connection and tcp/ip.
> > What I want to know what is the correct way to use it:
> > 1) Create a TIBDatabase component,establish a unique connection and the
pass
> > it to multiple instances of the datamodule
> >     throughout the thread.

> As long as the connection is being used by only one thread at a time,
> you can share it between as many DMs as you want.  For example, if you
> create 27 DMs in a single thread and use them concurrently within the
> thread, that's fine.  If you create 27 DMs, each in their own thread,
> then they'll all need their own connection to IB.

> > The way I understand it is that I must create one unique datamodule with
one
> > unique connection and use it throughout the thread.

> No, you can have many DMs in the thread using the same IB connection.
> I do this in my DataSnap servers.

> -Craig

> --
>  Craig Stuntz (TeamB) Vertex Systems Corp. Columbus, OH
> We're hiring: http://www.vertexsoftware.com/careerops.htm#sd
>      Delphi/InterBase WebLog: http://delphi.weblogs.com

Re:IBX and thread issues - TeamB


Quote
"Robert Leblanc" <rlebl...@vianet.on.ca> wrote in message

news:3c140b25$1_1@dnews...

Quote
> Just so I am  clear on this. Does this mean that - if I am creating an
ISAPI
> application using an Internet Express webmodule that contains an
> IBDatatabase component, an IBTransaction and an IBQuery component, I do
not
> have to do anything more (with respect to these IBX components) to ensure
> thread safety since separate web module instances are generated for each
> thread at runtime?

Correct. Something else was causing your previous problems, perhaps
transaction issues. I've built several ISAPI apps now using IBX with no
problems at all.

--
Wayne Niddery (Logic Fundamentals, Inc.)
RADBooks: http://www.logicfundamentals.com/RADBooks/delphibooks.html
Try to make original mistakes, rather than needlessly repeating [others]. -
Donald Rumsfeld, U.S. Secretary of Defense

Other Threads