#1 2020-11-23 06:57:22

radexpol
Member
From: Poland, Krk
Registered: 2019-11-29
Posts: 116

Callbacks freeze?

Let's say we have a 2000 callback listeners working on different network segments - some of them uses slow connections such as mobile 3G.

So in this situation:

procedure TChatService.BlaBla(const pseudo,msg: string);
var i: integer;
begin
  for i := high(fConnected) downto 0 do
    try
      fConnected[i].NotifyBlaBla(pseudo,msg);
    except
      InterfaceArrayDelete(fConnected,i);
    end;
end;

1. the loop speed will depend on client network speed and 2.freeze the main thread if I execute BlaBla from timer placed on Main Form. 3.The last client from fConnected array will wait very long time waiting for all previous notifications of that queue. 4.The solution is for example the thread pool for "notifictions worker" so it allows asynchronous notifications.

AB, can you answer for all 4 questions? Maybe NotifyBlaBla is already async?

Last edited by radexpol (2020-11-23 06:58:42)

Offline

#2 2021-01-02 10:55:05

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,237
Website

Re: Callbacks freeze?

Read the doc again about asynch callbacks.

If NotifyBlaBla is a procedure with no returned value (var/out parameter), it is already asynch.

Offline

Board footer

Powered by FluxBB