From: "Jeffrey R. Carter" <spam.jrcarter.not@spam.not.acm.org>
Subject: Re: Performance of many concurrent delay() calls
Date: Mon, 7 Nov 2016 15:42:33 -0700
Date: 2016-11-07T15:42:33-07:00 [thread overview]
Message-ID: <nvqvvu$33c$1@dont-email.me> (raw)
In-Reply-To: <1a375eea-b087-4080-a492-62bc26a8123c@googlegroups.com>
On 11/07/2016 11:52 AM, Olivier Henley wrote:
>
> Does calling [loop and delay(1.0)] for each of many thousand connected
> clients (gnoga/simple components) is a huge performance hit or not?
Both loop and delay are statements, and are not called.
> If so, what is the recommended way to implement a periodic, every sec,
> procedure that has to run for every clients; instantiate a single main task
> looping, delay(1.0), over all connections data and call the wanted
> procedure... probably?
From the context of Gnoga, a connection should usually spend most of its time
waiting for the user to do something. I'm going to presume that you want to do a
periodic update of all windows, with the updates not being synchronized, since
you're using a relative delay. In that case, having a task per connection that
spends most of its time in a delay and does something fairly quick when not
should not be a problem. You'd have a task component in the connection data that
would periodically update something in the connections window. You'd want a way
to keep the task from running until the window is set up.
type App_Info;
type App_Ptr is access all App_Info;
task type Updater (App : App_Ptr) is
entry Start;
entry Stop;
end Updater;
type App_Info is new Gnoga.Types.Connection_Data_Type with record
Window : Gnoga.Gui.Window.Pointer_To_Window_Class;
View : Gnoga.Gui.View.View_Type;
Form : Gnoga.Gui.Element.Form.Form_Type;
Count : Gnoga.Gui.Element.Form.Number_Type;
Update : Updater (App => App_Info'Unchecked_Access);
end record;
task body Updater is
Count : Natural := 0;
begin -- Updater
accept Start;
Forever : loop
select
accept Stop;
exit Forever;
or
delay 1.0;
Count := Count + 1;
App.Count.Value (Value => Count);
end select;
end loop Forever;
end Updater;
In the on-connect handler, after assigning Window and creating View, Form, and
Count, you'd call Update.Start. Your on-quit handler would call Update.Stop.
As this seems the clearest and simplest approach, you should try it first and
see if it meets your timing requirements.
--
Jeff Carter
"I certainly have not the talent which some people possess, ...
of conversing easily with those I have never seen before."
Pride and Prejudice
121
next prev parent reply other threads:[~2016-11-07 22:42 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-07 18:52 Performance of many concurrent delay() calls Olivier Henley
2016-11-07 19:04 ` J-P. Rosen
2016-11-07 19:13 ` Olivier Henley
2016-11-07 20:57 ` Dmitry A. Kazakov
2016-11-07 21:30 ` Florian Weimer
2016-11-07 22:42 ` Jeffrey R. Carter [this message]
2016-11-09 15:50 ` Olivier Henley
2016-11-09 23:15 ` Jeffrey R. Carter
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox