First Draft: Coroutines

Bienlein ffm2002 at web.de
Thu Nov 7 15:31:29 UTC 2024


On Tuesday, 6 August 2024 at 02:00:39 UTC, Richard (Rikki) Andrew 
Cattermole wrote:
> On 06/08/2024 6:11 AM, Sebastiaan Koppe wrote:
>> It is similar to the approach Go takes in that it makes 
>> calling C functions more difficult though.
>
> Go goes a bit further than that, their goroutines are 
> effectively in their own calling convention.
>
> We cannot replicate what they did, as we have strict 
> requirements on interactivity to C. I did check with Walter and 
> he confirmed it wasn't acceptable from his stance either.

D has fibers with which you can implement a thread model similar 
to the one in Go based on channels with blocking takes using 
green threads.

Actually, in project Loom carried out by Oracle the respective 
changeds wre made in JVM to bring fibers to the JVM. With the use 
of fibers some thread model was implemented that is quite close 
to the thread model in Go.

The work developed in project Loom has been released on the JVM 
since by Oracle since at least JDK 19.

So, something like communicating sequential processes (CS) as 
propsed by Tony Hoare and implemented by the people at Go into Go 
could also be brought to D. I think this would make D very 
interesting for sever-side development. Aside from server-side 
development, with CSP concurrent programming in general becomes a 
lot easier and less painful with fewer deadlocks and race 
cnditions from the beginning. When they still occur they are much 
easier to reproduce and understand and to fix them.




More information about the dip.development mailing list