🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c
Article #1593

Re: Inversion-of-control and dependency-injection in C

#1593
From: Ross Finlayson
Date: Mon, 16 Nov 2026 20:20
97 lines
6061 bytes
On 11/16/2026 12:04 PM, Ross Finlayson wrote:
> On 11/16/2026 10:09 AM, 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.
>
> Thanks for writing Bonita. I'd infer from "schrieb" that
> your user-agent locale country/language is DE/de or as
> variously for example about 2-letter and 3-letter country
> codes and accounts of language or ISO 601 or what I forget.
> Mann kann nur kleine Deutsch gesprechern, nicht viel das
> hier doch, aber los. Mein Wortschatz, es ist kaput.
>
>
> That said, _why_ I specifically am not using epoll/kqueue
> or io_uring instead pselect not select or poll, is:
> if you overload the epoll red/black tree or io_iuring queues
> respectively, they drop messages. Now, most of the time,
> that's accommodated by some absurdly simple back-end like
> "send" that tolerates drops itself, in things like message-bus.
> Then, epoll for example, on a wake-up or return from the blocking
> syscall, doesn't notify twice when there remains data to be read.
> Then, pselect() may be blocking and furthermore with the impact
> that the kernel polls the sockets busily, yet, pselect() can
> timeout itself, for example, and register interest on active
> selectors and only periodically eg 5ms register interest on
> active + inactive selectors (file-descriptors).
>
> Then, there's a fact that POSIX runtimes have signals,
> then, that pselect() behaves in a more defined manner.
>
> Another key distinction is that: buffers for use with
> epoll and I believe also kqueue, or io_uring, must
> be "pinned" with mlock() or what, to physical memory,
> for the kernel to treat them, instead of copying from
> user-space to kernel-space or vice-versa or however
> the runtime may care to swap pages under addresses
> with making copies, that for accounts of vector I/O,
> scatter/gather yet mostly vector I/O for the bus boss
> the DMA, it's just plain old heap RAM.
>
>
> Then, also pselect() is POSIX and so it's portable.
> It's less code if it doesn't need multiple back-ends
> for various platforms' implementations of I/O multiplexing.
>
>


Why don't they just call std::coroutine "fiber"?



About asynchronous-concurrency, and, progress without starvation,
and, parallelism, and task-level parallelism vis-a-vis instruction-level
parallelism, the "re-routine" account
basically makes a model of asynchronous concurrency
"in the language, well, with a subset of the libraries of
the language", with "automatic parallelization of independent
tasks", in a sort of account of framework.

"Computronomat: the re-routine, a model of co-operative co-routine"


Anyways I suppose I mentioned that before, the re-routine, ....

Have I mentioned the re-routine?



About asynchrony, there's basically that co-operative multithreading,
requires yield, and, call-backs. This is implicit in many accounts of
event loops with short-running functions and get tossed back atop
the event loop queue. Re-routines just implicitly always yield
when any logical dependency is unsatisfied and it's all callbacks and
callbacks just re-enter the re-routine.



Yeah, I know, basta, enough, enough, basta, I know, I know.

It'd be great to have a model of co-operative co-routine in the
language, ....

Technical Details
Message-ID: <bCOdnXeY-Pku-Gb3nZ2dnZfqn_adnZ2d@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!local-3.nntp.ord.giganews.com!Xl.tags.giganews.com!local-4.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mail
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> <dmKdnV8-pPdQ_Gb3nZ2dnZfqnPadnZ2d@giganews.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!local-3.nntp.ord.giganews.com!Xl.tags.giganews.com!local-4.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Mon, 16 Nov 2026 20:21:06 +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>
 <dmKdnV8-pPdQ_Gb3nZ2dnZfqnPadnZ2d@giganews.com>
From: Ross Finlayson <ross.a.finlayson@gmail.com>
Date: Mon, 16 Nov 2026 12:20:40 -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: <dmKdnV8-pPdQ_Gb3nZ2dnZfqnPadnZ2d@giganews.com>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Message-ID: <bCOdnXeY-Pku-Gb3nZ2dnZfqn_adnZ2d@giganews.com>
Lines: 97
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-rziV365VlrtgGDOIQGJCCLP2pLIlqmhhtm+Qoj14BlGWf1zZNGgnV96QTMaxAE2rujYgXVGaYedt+Za!w9FBHoQ/dUvxuIJWJmREe6PVzZ8rdgolm2NxZE+7VxvTzzvwWWnuOwlJZTQnkr/WyKHTx41hIRwd
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