Re:Tree-Structured Concurrency
by bluejekyll on Sunday July 02, 2023 @10:07AM
(#36561610)
This sounds like what scoped threads at least partially provides. It was in pre-1.0 Rust, got moved to a 3rd party library, but stabilized in 1.63: https://doc.rust-lang.org/stable/std/thread/fn.scope.html
[ Parent
| on HN ]
Re:Tree-Structured Concurrency
by thesuperbigfrog on Sunday July 02, 2023 @12:28PM
(#36562985)
Some of the features are there, but not all:
It looks like each thread in scoped threads must be "manually started" (not launched automatically at the beginning of the scope).
No defined mechanisms for synchronization or data passing between scoped threads. There are probably ways it can be done, but I am not sure what approach would work best without some experimentation.
In Rust, the idiomatic solutions for data-passing would be a fifo channel (either std::sync::mpsc from the standard library or one of the popular libraries (crossbeam or flume)), and the solution for synchronization would be one-shot channels or zero-capacity channels.
Or you can just manually join the threads you started