Hello,
My service works as expected with RTC without multi-threading
Thanks
Now I'll try to use the power of RTC when
MultiThreaded=TRUE and
Blocking=FALSE.
I am trying to understand the WebStressTool project.
I am reading the helpfile, source code etc...
In RTCHelp.chm I can read
VERY IMPORANT!!! If you create connection components at runtime:
* NEVER! use Create(), Free or Destroy on ANY connection component.
* Allways use the 'NEW' class function (implemented by all TRtcConnection
components) to create the connection object and
* ONLY use the 'RELEASE' method to free the connection object.
Is it only true in case I create my own class (inherited from a TRtcConnection)?
If not I wonder why you never use
new and
release in any project (like WebStressTool).
My knowledge in English is quite limited.
And I should appreciate if you can drop a word about the need to use New/Release.
I have another question concerning RTC_THREAD_POOL_MAX.
Sometimes I want to change the value of RTC_THREAD_POOL_MAX (when my service starts for instance).
(I know that I DONT have to change it until connections are active)
And sometimes I need to know if the pool is busy (not between a OpenThreadPool..CloseThreadPool in rtcThrPool.pas).
(I also need to know if the pool is busy to delay the service shutdown.)
I wrote a function
ThreadPoolCount in rtcThrPool.pas
function ThreadPoolCount:Cardinal;
begin
CSThread.Enter;
try
if Assigned(ThreadPool) then
Result:=ThreadPool.Count
else
Result:=0;
finally
CSThread.Leave;
end;
end;
Example of use:
NewThreadPoolMax:=Ini.ReadInteger('Options', 'ThreadPoolMax',32);
if (NewThreadPoolMax<>RTC_THREAD_POOL_MAX) then
begin
if ThreadPoolCount = 0 then
RTC_THREAD_POOL_MAX:=NewThreadPoolMax
else
LogError(Format( 'Warning Init RTC ThreadPoolMax (RTC busy, %d<>%d)',[RTC_THREAD_POOL_MAX, NewThreadPoolMax ]));
end;
Is there a better way to do the job ?
Kind Regards
Barbaland