[OT] Senders and Receivers

Sebastiaan Koppe mail at skoppe.eu
Wed Jun 4 21:48:07 UTC 2025


On Wednesday, 4 June 2025 at 19:59:27 UTC, Ali Çehreli wrote:
> On 6/2/25 11:06 PM, Paul Backus wrote:
>
> > The main thesis (quoted from the article's conclusion) is
> this:
> >
> >> These [unstructured concurrency] primitives are dangerous
> even if we
> >> don't use them directly, because they undermine our ability
> to reason
> >> about control flow and compose complex systems out of
> abstract modular
> >> parts, and they interfere with useful language features like
> automatic
> >> resource cleanup and error propagation.
>
> The garbage collector wins in that scenario because it removes 
> the need for "automatic resource cleanup" e.g. of C++.
>
> That fact was pointed out to me by a colleague years ago: The 
> sender threads generate messages, the receiver threads use 
> those messages, and thanks to the garbage collector, nobody 
> cares about the ownership of messages.
>
> Ali

It is not the lifetimes of the messages that is interesting, it's 
that of the producer and consumer themselves instead.

This is because they are different sides of the same coin; one 
without the other wouldn't work. The essential point is thus to 
model that relationship correctly - to ensure their lifetimes are 
coupled and avoid one going off without the other. Getting that 
guarantee is the big benefit of SC. Just look at the link I 
posted and read the papers it links to. Almost all those bugs are 
variations of mishaps in ensuring that invariant manually, not a 
good way to go about it.

Now, it must be said, the GC does help a lot in lock-free 
algorithms. Just look into hazard pointers to see what madness 
you have to resort to without a GC.


More information about the Digitalmars-d mailing list