Re: [twsocket] ICS Message handlers

2010-08-18 Thread Anton S.
Eric, talking about your shared timer: do you call OnTimer of all attached 
objects directly or post WM_TIMER to them? I had though over the same timer 
class and that was my idea to broadcast timer signal. I think it'll eliminate 
the issue of blocking during loop since PostMessage is asynchronous. But I'm 
not sure, maybe it'll overload message queues.

-- 
Anton
--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] ICS Message handlers

2010-08-18 Thread Eric Fleming Bonilha

Hi Anton,

I call it directly, in order not to allocate handlers, if you create a class 
with a handle and post a message to it, it will be the same as using TTimer 
directly, because you will use as many resources as TTimer would use (1 
handle per instance), unless you create a class that is derived from 
TICSWndControl (Which I´m trying to do, but I found a bug in its message 
handling implementation and I´m waiting for someone to check it), than you 
can share some resources.


I just created this class because I was using many resources and resources 
are limited ;)


But I was thinking on something, and I would like someone to confirm it or 
explain me better


Using for example, 1.000 instances of TTimer at 1 second triggering, the 
messages will be received and processed *in a loop* at the main thread, 
wouldn´t be almost the same as having a loop to trigger the event of all 
ttimers by the shared timer?


Eric

--
From: "Anton S." 
Sent: Wednesday, August 18, 2010 10:48 AM
To: 
Subject: Re: [twsocket] ICS Message handlers

Eric, talking about your shared timer: do you call OnTimer of all attached 
objects directly or post WM_TIMER to them? I had though over the same 
timer class and that was my idea to broadcast timer signal. I think it'll 
eliminate the issue of blocking during loop since PostMessage is 
asynchronous. But I'm not sure, maybe it'll overload message queues.


--
Anton
--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be






Nenhum virus encontrado nessa mensagem recebida.
Verificado por AVG - www.avgbrasil.com.br
Versao: 9.0.851 / Banco de dados de virus: 271.1.1/3079 - Data de 
Lancamento: 08/18/10 03:35:00



--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


[twsocket] Suggestion for improvement

2010-08-18 Thread Eric Fleming Bonilha
Hello

I would suggest the changing of constant WH_MAX_MSG in 
OverbyteIcsWndControl.pas to a global variable to which we can change on our 
software, without changing ICS code.

Doing this will allow us to control the amount of shared resources per handle, 
giving the ability to create more sockets on a software that already uses many 
system handles

Eric
--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] ICS Wnd Control - Possible bug

2010-08-18 Thread Arno Garrels
Eric,

I guess it helps to remove all pending messages with the given ID
from the queue when the message ID is unregistered.

One could do that either in custom code or maybe it should
be added in TIcsWndHandler.UnregisterMessage as below?

procedure TIcsWndHandler.UnregisterMessage(var Msg: UINT);
var
LMsg: TMsg; // <== added
begin
if Msg = 0 then
Exit;
if FMsgLow < WM_USER then
raise EIcsException.Create('MsgLow not defined');
if Msg >= (FMsgLow + WH_MAX_MSG) then
raise EIcsException.Create('Msg value out of bound');
if not Assigned(FMsgMap[Msg - FMsgLow]) then
raise EIcsException.Create('Msg not registered');
FMsgMap[Msg - FMsgLow] := nil;
Dec(FMsgCnt);
Msg := 0;
while PeekMessage(LMsg, FHandle, Msg, Msg, PM_REMOVE) do {loop}; // <== 
added
if FMsgCnt = 0 then
DeallocateHWnd;
end;

-- 
Arno Garrels
--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] ICS Wnd Control - Possible bug

2010-08-18 Thread Eric Fleming Bonilha

HI Arno

True, I think that will help, I will add this line to my ICS code to check 
if it works, but I believe that it will work


I also think that this is something that must be on ICS code, on 
UnregisterMessage as you proposed, not custom code.


I will test and come back to you soon

Eric


--
From: "Arno Garrels" 
Sent: Wednesday, August 18, 2010 11:43 AM
To: "ICS support mailing" 
Subject: Re: [twsocket] ICS Wnd Control - Possible bug


Eric,

I guess it helps to remove all pending messages with the given ID
from the queue when the message ID is unregistered.

One could do that either in custom code or maybe it should
be added in TIcsWndHandler.UnregisterMessage as below?

procedure TIcsWndHandler.UnregisterMessage(var Msg: UINT);
var
   LMsg: TMsg; // <== added
begin
   if Msg = 0 then
   Exit;
   if FMsgLow < WM_USER then
   raise EIcsException.Create('MsgLow not defined');
   if Msg >= (FMsgLow + WH_MAX_MSG) then
   raise EIcsException.Create('Msg value out of bound');
   if not Assigned(FMsgMap[Msg - FMsgLow]) then
   raise EIcsException.Create('Msg not registered');
   FMsgMap[Msg - FMsgLow] := nil;
   Dec(FMsgCnt);
   Msg := 0;
   while PeekMessage(LMsg, FHandle, Msg, Msg, PM_REMOVE) do {loop}; // <== 
added

   if FMsgCnt = 0 then
   DeallocateHWnd;
end;

--
Arno Garrels
--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be






Nenhum virus encontrado nessa mensagem recebida.
Verificado por AVG - www.avgbrasil.com.br
Versao: 9.0.851 / Banco de dados de virus: 271.1.1/3079 - Data de 
Lancamento: 08/18/10 03:35:00



--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] ICS Wnd Control - Possible bug

2010-08-18 Thread Eric Fleming Bonilha

   Msg := 0;
   while PeekMessage(LMsg, FHandle, Msg, Msg, PM_REMOVE) do {loop}; // <== 
added

   if FMsgCnt = 0 then
   DeallocateHWnd;
end;


Just a little correction

   while PeekMessage(LMsg, FHandle, Msg, Msg, PM_REMOVE) do {loop}; // <== 
added

   Msg := 0;


Or else you will pass 0 to PeekMessage


Eric


--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] ICS Wnd Control - Possible bug

2010-08-18 Thread Arno Garrels
Arno Garrels wrote:
> Eric,
> 
> I guess it helps to remove all pending messages with the given ID
> from the queue when the message ID is unregistered.
> 
> One could do that either in custom code or maybe it should
> be added in TIcsWndHandler.UnregisterMessage as below?

Previous code did remove message ID 0 (I should not code in OE 8-)
corrected code:

procedure TIcsWndHandler.UnregisterMessage(var Msg: UINT);
var
LMsg: TMsg; // <== added
begin
if Msg = 0 then
Exit;
if FMsgLow < WM_USER then
raise EIcsException.Create('MsgLow not defined');
if Msg >= (FMsgLow + WH_MAX_MSG) then
raise EIcsException.Create('Msg value out of bound');
if not Assigned(FMsgMap[Msg - FMsgLow]) then
raise EIcsException.Create('Msg not registered');
FMsgMap[Msg - FMsgLow] := nil;
Dec(FMsgCnt);
while PeekMessage(LMsg, FHandle, Msg, Msg, PM_REMOVE) do {loop}; // <== 
added
Msg := 0;
if FMsgCnt = 0 then
DeallocateHWnd;
end;
--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] Suggestion for improvement

2010-08-18 Thread Arno Garrels
Eric Fleming Bonilha wrote:
> I would suggest the changing of constant WH_MAX_MSG in
> OverbyteIcsWndControl.pas to a global variable to which we can change
> on our software, without changing ICS code.

That won't work since TIcsWndHandler declares a static array with 
length WH_MAX_MSG. 
Instead I suggest that TIcsWndHandlerPool gets a public, thread-safe 
method which checks whether the value can be changed and would raise
an exception if not. This method would succeed only if the pool
was empty (when no instance of TWndControl existed) and the value
passed was in the range 50-1000, anything beyond makes no
sense IMO.

Setting the maximum number of messages per handler would be
just one line:
GWndHandlerPool.SetMaxMsgPerHandler(200); 

The GWndHandlerPool variable is assigned in OverbyteIcsWndControl's
initialization section.

-- 
Arno Garrels  


--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] Suggestion for improvement

2010-08-18 Thread Eric Fleming Bonilha

That won't work since TIcsWndHandler declares a static array with
length WH_MAX_MSG.
Instead I suggest that TIcsWndHandlerPool gets a public, thread-safe
method which checks whether the value can be changed and would raise
an exception if not. This method would succeed only if the pool
was empty (when no instance of TWndControl existed) and the value
passed was in the range 50-1000, anything beyond makes no
sense IMO.

Setting the maximum number of messages per handler would be
just one line:
GWndHandlerPool.SetMaxMsgPerHandler(200);

The GWndHandlerPool variable is assigned in OverbyteIcsWndControl's
initialization section.



That is good too, we just need a method to increase the value, 200 is good 
;)


Eric 


--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be