An idea; Coroutines

Sebastiaan Koppe mail at skoppe.eu
Tue Jan 16 21:15:55 UTC 2024


On Tuesday, 16 January 2024 at 20:43:19 UTC, Richard (Rikki) 
Andrew Cattermole wrote:
> On 17/01/2024 9:23 AM, Sebastiaan Koppe wrote:
>> We did an implementation at 
>> https://github.com/symmetryinvestments/concurrency which I am 
>> (very slowly) cleaning up and prepping for inclusion into 
>> Phobos.
>
> I think I did look at it at some point, but went yeah this is 
> way more complex than what I need.

That was my reaction too, but the moving parts are actually a lot 
simpler than they look.

Furthermore they do this with great composability, with 
practically no allocations, and, most importantly, using 
structured concurrency principles.

> It may be possible that the language coroutine support may be 
> able to drive it. Which could be worth considering.

Its the other way around really.

I have already been able to integrate them with Threads, Fibers, 
epoll, iouring, iocp, even with external C eventloops.

The C++ folks have them integrated with their stackless 
coroutines as well.

Sender/Receivers is the simplest complete model for asynchronous 
computation I have come across. Emphasize on complete.

Not saying we have to copy at verbatim, but they have a lot that 
we should at least consider.

My pet peeve is the typical lack of support for cancellation many 
async libs have. While in reality it should be front and center.


More information about the Digitalmars-d mailing list