Article View: comp.lang.c
Article #1699Re: Inversion-of-control and dependency-injection in C
From: Ross Finlayson
Date: Fri, 20 Nov 2026 14:03
Date: Fri, 20 Nov 2026 14:03
84 lines
5511 bytes
5511 bytes
On 11/20/2026 05:12 AM, Michael S wrote: > On Fri, 20 Nov 2026 12:35:25 +0000 > Tristan Wibberley <tristan.wibberley+netnews2@alumni.manchester.ac.uk> > wrote: > >> On 16/11/2026 18:09, Bonita Montero wrote: >>> Am 13.11.2026 um 23:50 schrieb Ross Finlayson: >>> >>>> So, here's one. Say you got a server process for sockets of the >>>> connection-oriented or datagram-wise or association-oriented like >>>> TCP, UDP, or SCTP, and it manages the connecting and the sending >>>> and receiving about a million of those and is sort of fixed-size >>>> and stable in a usual runtime. So, how do you design the interface, >>>> about stuff like the state-machine of _protocols_, all about >>>> _protocols_, in the application-layer and above, say, for example >>>> the incremental-parsing and the state-machine of the protocol >>>> and sub-protocols and upgrade-protocols and the like, what sort >>>> of abstraction with suitable-defaults and reasonable-opinions >>>> makes for having any sort protocol as a composable library. >> >>> Use C++20 coroutines with Bost.ASIO and io_uring. This gives >>> as less code as possible with nearly optimal I/O performance. >> >> I like this answer. >> >> It's funny: people used coroutines and CoEs back in the 1970s (I did >> it as a child, myself), then everyone told each other to stop it, now >> 50 years later here we are again, finally succeeding once more after >> a long hiatus, albeit with appalling syntax and semantics everywhere >> around it like thorny bushes. >> > > Not every co-routine syntax is as bad as one of C++. > C# async is better. > May be, even Rust is better, at cost on reliance on magic barely > documented tokio runtime. > > Me, personally? > I accepted the idea of language-managed stackless co-routines when heard > about it first time. But with time passing I like it less and less. > More and more I tend to think that what I really would like are > normal co-routines, a.k.a. fibers, not necessarily as part of the > language. > > Or just do as golang, leaving selection between fibers and > kerner-visible threads to language runtime. Hopefully, I did not > misrepresent golang approach to badly :( > > > > > One may get the impression that std::coroutine or verbally "s.t.d.-namespace co-routine", much "is" fibers, after an account of the semantics and a re-write rule, much reflecting the 'Soft's deserved if sometimes underservedly the influence in the development of the standards, and accelerating that development to promote their tools, vis-a-vis the stability of interface and standards and specification and interoperability. Go's "select" basically is about POSIX's "select", with some nice syntactic-sugar and for lambdas in the language. The account of std::coroutine and availables and that, like as the model of "fibers" as co-operating switching among function bodies during a thread's time-slice, giving-or-taking accounts of stack abstraction, or "execution and par" and this kind of thing, or even for example "std::simd" and the like, about accounts of both parallelism, for the parallelizable, and concurrency, for the throughput or for example "transput" as Finkel put it in "An Operating Systems Vade Mecum" a great account of a walk-through of most usual accounts of operating-systems then widened for the distributed-world, makes for that _protocols are protocols_, and Postel & Murphy's laws has that Postel's law is a good guideline, describing good-actors in well-defined protocols, and Murphy's is in effect. (I'm a big fan of "concepts" in C++, if not so relevant here.)
Technical Details
Message-ID:
<Qaycnb7dhf-szp32nZ2dnZfqnPWdnZ2d@giganews.com>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srv.newsdeef.eu!weretis.net!feeder9.news.weretis.net!border-2.nntp.ord.giganews.com!nntp.giganews.com!Xl.tags.giganews.com!local-3.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mailReferences:
<yQOdnQ-qnKiiZ2j3nZ2dnZfqn_udnZ2d@giganews.com> <11d56gl$3ud5q$1@dont-email.me> <11d6vjp$qhu8$1@raubtier-asyl.eternal-september.org> <dsednTD-Fblclmr3nZ2dnZfqnPWdnZ2d@giganews.com> <11d738r$ru7a$1@dont-email.me> <11d75i7$spj0$1@dont-email.me> <11d7c8k$173nk$1@dont-email.me> <11d7fbv$1839o$2@dont-email.me> <nrecnTdvuvbACWr3nZ2dnZfqn_adnZ2d@giganews.com> <11dfgtf$3pj6i$1@raubtier-asyl.eternal-september.org> <11dpeqd$35ddj$1@dont-email.me> <20261120151218.00007f53@yahoo.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srv.newsdeef.eu!weretis.net!feeder9.news.weretis.net!border-2.nntp.ord.giganews.com!nntp.giganews.com!Xl.tags.giganews.com!local-3.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mail NNTP-Posting-Date: Fri, 20 Nov 2026 14:03:29 +0000 Subject: Re: Inversion-of-control and dependency-injection in C Newsgroups: comp.lang.c References: <yQOdnQ-qnKiiZ2j3nZ2dnZfqn_udnZ2d@giganews.com> <11d56gl$3ud5q$1@dont-email.me> <11d6vjp$qhu8$1@raubtier-asyl.eternal-september.org> <dsednTD-Fblclmr3nZ2dnZfqnPWdnZ2d@giganews.com> <11d738r$ru7a$1@dont-email.me> <11d75i7$spj0$1@dont-email.me> <11d7c8k$173nk$1@dont-email.me> <11d7fbv$1839o$2@dont-email.me> <nrecnTdvuvbACWr3nZ2dnZfqn_adnZ2d@giganews.com> <11dfgtf$3pj6i$1@raubtier-asyl.eternal-september.org> <11dpeqd$35ddj$1@dont-email.me> <20261120151218.00007f53@yahoo.com> From: Ross Finlayson <ross.a.finlayson@gmail.com> Date: Fri, 20 Nov 2026 06:03:01 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: <20261120151218.00007f53@yahoo.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <Qaycnb7dhf-szp32nZ2dnZfqnPWdnZ2d@giganews.com> Lines: 84 X-Usenet-Provider: http://www.giganews.com X-Trace: sv3-horbws1G67UPYklsDGmp4fj4Z5e9BZkNa203oxisLpeww7bw7ekf9MqEbKBX4Yhx5trzZ0VhRwuRi8g!Cbi/+LkfXJHryH3ydJ8SiXZPhIbT0JkiBMjLHMdazviYyf6hivb12xJtlVUtKBXdjIpZ9M8m2KLS X-Complaints-To: abuse@giganews.com X-DMCA-Notifications: http://www.giganews.com/info/dmca.html X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40