News for hackers. Stuff that matters.
Re:Structured Concurrency by zozbot234 on Saturday March 19, 2022 @10:57PM (#30739652)
I don't think this can be made to work. Concurrent systems are usually modeled using things like e.g. Petri nets that are not really "highly structured" by your definition. They may be more structured than a goto statement, but they aren't nearly as simple as the pure fork-join model that's often regarded as the typical case of "structured" concurrency.

Even the first diagram in OP has free interleaving of main() with quux() then foo() that's not well described by a "tree" of fork-join "tasks". (The second diagram is similarly complex in that foo() may want to transfer ownership of bar() to main(), in order to cleanly terminate and allow main() to proceed prior to waiting for bar().)

Re:Structured Concurrency by ghoward on Saturday March 19, 2022 @11:57PM (#30739956)
You're probably right that my rough sketch for a proof wouldn't work.

That said, first of all, I don't think structured concurrency has to be a tree. I think it can be a DAG. See my comment at [0].

To solve the main(), quux(), foo() problem, just have main() open a threadset, spawn quux(), then call a function while the threadset is still open, and in that function, open another threadset that spawns foo().

The main(), foo(), bar() problem is a problem of cancellation. In that one, I believe that foo() should not return until bar() does. And if you need to cancel, use deadlines. That is why my code has cancellation built-in, with timers to implement deadlines. (Well, it's still alpha, but the rough shape of it is there.)

[0]: https://lobste.rs/s/8msejg/notes_on_structured_concurrency_g...