help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <>
Subject: Re: Broadcast / iterate to all Connection objects via Simple Components?
Date: Mon, 13 Feb 2023 11:55:07 +0100	[thread overview]
Message-ID: <tsd4ua$23ce9$> (raw)
In-Reply-To: <>

On 2023-02-13 09:44, Emmanuel Briot wrote:
>> sockets (socket select).
> Have you taken a look at epoll(), on linux ?

The implementation is on top of GNAT.Sockets, so no.

> It is so much more natural to use, and so much more efficient in practice.
> The example I mentioned above (a server with 25_000 concurrent connections) cannot work with select (which only
> accepts file descriptors up to 1024), and is slow with poll (since the result of the latter is the number of events, and we
> need to iterate over all registered sockets every time).

Well, if there is Linux kernel level support why it is not used in 
socket select as it is in epoll? I would expect them do that at some 
point or drop epoll... (:-))

>> P.S. This poses difficulties for users, who see all communication turned
>> upside down being driven by arbitrary socket events rather than by the
>> protocol logic. This was a reason I argued for introducing co-routines
>> with task interface in Ada.
> In my own code, I basically provide an epoll-based generic framework.  One of the formal parameters is a `Job_Type`
> with one primitive operation `Execute`.
> The latter is initially called when a new connection is established, and is expected to do as much non-blocking work
> as it can (Execute is run in one of the worker tasks).  When it cannot make progress, it returns a tuple (file_descriptor, type_of_event_to_wait_for)
> to indicate when it needs to be called again in the future, for instance some data became available to read on the
> specified file_descriptor.
> The intent is that the `Job_Type` is implemented as a state machine internally.

Yes, state machine is what I want to avoid. With complex layered 
protocols it imposes incredible difficulties requiring auxiliary stacks 
and buffers with errors almost intractable either by testing or by 
formal proofs.

> Of course, a state machine is one of the two ways I know (along with a task) to implement the equivalent of
> a co-routine in Ada.  So I 100% agree with you that co-routines would be very useful in simplifying user code,
> in particular in the scenario we are discussing here !

I'd like to have special Ada "tasks" acting as co-routines on top of 
proper tasks yielding when the socket buffer is empty or full.

Dmitry A. Kazakov

  reply	other threads:[~2023-02-13 10:55 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-07 20:29 Broadcast / iterate to all Connection objects via Simple Components? A.J.
2023-02-08  8:55 ` Dmitry A. Kazakov
2023-02-08  9:55 ` Jeffrey R.Carter
2023-02-13  7:28   ` Emmanuel Briot
2023-02-13  8:30     ` Dmitry A. Kazakov
2023-02-13  8:44       ` Emmanuel Briot
2023-02-13 10:55         ` Dmitry A. Kazakov [this message]
2023-02-13 11:07           ` Emmanuel Briot
2023-02-13 11:57             ` Dmitry A. Kazakov
2023-02-13 13:22               ` Niklas Holsti
2023-02-13 15:10                 ` Dmitry A. Kazakov
2023-02-13 16:26                   ` Niklas Holsti
2023-02-13 19:48                     ` Dmitry A. Kazakov
2023-02-15  9:54                       ` Niklas Holsti
2023-02-15 10:57                         ` Dmitry A. Kazakov
2023-02-15 18:37                           ` Niklas Holsti
2023-02-19  1:27                             ` A.J.
2023-02-19  8:29                               ` Dmitry A. Kazakov
2023-02-19 14:37                               ` Niklas Holsti
2023-02-13 15:43                 ` J-P. Rosen
2023-02-13 16:40             ` Jeremy Grosser <>
2023-02-13 20:33 ` Daniel Norte de Moraes
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox