 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Offir Bakshitz Guest
|
Posted: Wed Jan 26, 2005 9:49 am Post subject: Preventing the activation of the IdAntiFreeze mechanism |
|
|
Hi all,
While debugging my application i noticed that every call to
TIdTCPClient.Connect() yields the creation of a new thread.
After Furthur study I realized that Indy has a mechanism that processes all
messages to prevent the main thread from blocking while the application
calls connect() from the main thread.
Since my application creates a thread in which conenct() is called, If feel
I do not need the extra "anti-freeze" thread.
What is the right way to prevent indy from creating this anti-freeze thread?
Is it indeed true that if I call TIdTCPClient.Connect() from a worker-thread
I do not need the extra antifreeze thread?
Thanks.
Offir.
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Wed Jan 26, 2005 10:29 am Post subject: Re: Preventing the activation of the IdAntiFreeze mechanism |
|
|
"Offir Bakshitz" <nospam> wrote
| Quote: | While debugging my application i noticed that every call to
TIdTCPClient.Connect() yields the creation of a new thread.
|
Correct, because the only way to abort a blocking connect is to close the
socket from another thread. That is how Connect() implements its timeout
capability.
| Quote: | Since my application creates a thread in which conenct() is called,
If feel I do not need the extra "anti-freeze" thread.
|
The thread that Connect() creates is not an anti-freeze thread.
TIdAntiFreeze does not do anything when called from a worker thread. The
thread that Connect() creates handles the actual connecting itself.
| Quote: | What is the right way to prevent indy from creating this anti-freeze
thread? |
If a worker thread calls Connect(), TIdAntiFreeze is not used.
As for the thread that controls the connect itself, there is no way to
prevent that thread from being used. It is part of the implementation for
Connect(). Remove the thread and the Timeout feature will no longer work.
Gambit
|
|
| Back to top |
|
 |
Offir Bakshitz Guest
|
Posted: Wed Jan 26, 2005 11:08 am Post subject: Re: Preventing the activation of the IdAntiFreeze mechanism |
|
|
The reason I am worried about the extra thread is that my application
creates many (over a hundred) threads that besides DB operations also call
connect(). I cannot affort having double this already high number of
threads.
My application defines a value for TIdTCPClient.ConnectTimeout, But if I set
the TIdTCPClient.ConnectTimeout to zero, and call TIdTCPClient.Connect()
(not from the main thread), then the extra thread will not be created,
right?
If I use ConnectTimeout = 0, will the thread that call connect() block
forever or will there still be a timeout? (I am not really worried about
being able to define this timeout, as long as there is one and not a
block-forever).
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Wed Jan 26, 2005 6:36 pm Post subject: Re: Preventing the activation of the IdAntiFreeze mechanism |
|
|
"Offir Bakshitz" <nospam> wrote
| Quote: | My application defines a value for TIdTCPClient.ConnectTimeout
|
Are you using Indy 10?
| Quote: | But if I set the TIdTCPClient.ConnectTimeout to zero, and call
TIdTCPClient.Connect() (not from the main thread), then the extra
thread will not be created, right?
|
Correct.
| Quote: | If I use ConnectTimeout = 0, will the thread that call connect()
block forever or will there still be a timeout? (I am not really
worried about being able to define this timeout, as long as there
is one and not a block-forever).
|
If the socket fails to connect to the server, an error will eventually
occur.
Gambit
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|