From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on ip-172-31-65-14.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-0.0 required=3.0 tests=BAYES_20,FREEMAIL_FROM, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Received: by 2002:ac8:404c:0:b0:3b9:b985:a17a with SMTP id j12-20020ac8404c000000b003b9b985a17amr613861qtl.12.1676770023190; Sat, 18 Feb 2023 17:27:03 -0800 (PST) X-Received: by 2002:a05:6830:26f2:b0:68d:b51a:5cf6 with SMTP id m50-20020a05683026f200b0068db51a5cf6mr323713otu.7.1676770022854; Sat, 18 Feb 2023 17:27:02 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sat, 18 Feb 2023 17:27:02 -0800 (PST) In-Reply-To: Injection-Info: google-groups.googlegroups.com; posting-host=2600:4040:7208:8d00:5d41:d4e4:8524:74a2; posting-account=es6tdQoAAABG0JD-zg4XEg34h5fepyKP NNTP-Posting-Host: 2600:4040:7208:8d00:5d41:d4e4:8524:74a2 References: <392dd5d3-4df1-403f-b703-ee6f750dbc81n@googlegroups.com> <02802bf3-fc29-44da-bd79-21f26d122203n@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Broadcast / iterate to all Connection objects via Simple Components? From: "A.J." Injection-Date: Sun, 19 Feb 2023 01:27:03 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Received-Bytes: 4131 Xref: reader01.eternal-september.org comp.lang.ada:64938 List-Id: Thank you for all of the responses and discussion, it pointed me in the rig= ht direction! The "chat server"[1] (if you could call it that) does work, = and my friends and I were able to telnet into it and chat. One of my frien= ds even tried throwing things at the server to break it, but it didn't cras= h! Dmitry, maintaining a list of clients was the vital part I was missing. I = played around with using synchronized queues and tasks, but ended up defaul= ting to an ordered map with a UID as the key and wrapped it in a protected = type. I couldn't get Send() to send more data than Available_To_Send (afte= r calling it, Available_To_Send ended up returning 0, and continued to do s= o despite wrapping Send() in a loop), but increasing the send buffer to 8kb= per connection worked fine. I would simply loop through that ordered map = each time I needed to send something to all of the clients. I really like simple components, and it would be neat if the GNAT maintaine= rs implement epoll in the backend for linux systems, kqueue for BSD and Mac= OS. Any server I write will be for linux though anyway. I'm also interest= ed in trying to benchmark Simple Component's connections server (both poole= d and standard) against epoll to see how it fares. Perhaps the clever task= ing that the Connections Server utilizes can keep up with epoll despite wha= t GNAT.Sockets utilizes! Regarding coroutines vs tasks, I think at a high level it's hard to differe= ntiate, but at a lower level, when I think of tasks vs what a coroutine wou= ld be, I think of Go, and their "goroutines."[2] Creating a task in Ada, a= t least on linux, ends up creating a pthread, and you get all of the overhe= ad that comes with threading (it's initialized in the kernel). coroutines = are managed by the go runtime (I believe in user space) and have much less = overhead to create or manage, since it's not creating a specific thread. Ada 202x supports the "parallel" block[3] though I understand no runtime ha= s utilized it yet-- would that end up being a coroutine or is it meant for = something else? [1] https://github.com/AJ-Ianozi/protohackers/tree/main/budget_chat/src [2] https://www.geeksforgeeks.org/golang-goroutine-vs-thread/ [3] http://www.ada-auth.org/standards/22rm/html/RM-5-6-1.html Kind regards, AJ.