Re:Libdill: Structured Concurrency for C (2016)
by ibraheemdev on Tuesday June 01, 2021 @03:56PM
(#27360386)
I wonder if this idea could be implemented in Rust with destructors.
[ Parent
| on HN ]
Re:Libdill: Structured Concurrency for C (2016)
by Matthias247 on Tuesday June 01, 2021 @06:03PM
(#27362017)
You can do it for Rust threads - but it gets tricky with Rust coroutines (async functions).
I made an attempt of implementing it for async Rust in
https://github.com/tokio-rs/tokio/issues/1879
with a concrete implementation in
https://github.com/tokio-rs/tokio/pull/2579
It mostly follows the Kotlin model of structured concurrency. However it has its sets of drawbacks due to Rust Futures being immediately cancellable, which then leads to problem if a parent task gets simply dropped.
In order to handle that case better I've written a proposal for async functions that run to completion with https://rust-lang.zulipchat.com/#narrow/stream/187312-wg-asy... . However that is all theoretical, and might never see the light of the day.
Re:Libdill: Structured Concurrency for C (2016)
by staticassertion on Tuesday June 01, 2021 @04:12PM
(#27360629)
Drop is synchronous, and it's unclear what async Drop would look like afaik, so not today.
Re:Libdill: Structured Concurrency for C (2016)
by ibraheemdev on Tuesday June 01, 2021 @04:18PM
(#27360709)
The drop implementation could push to a worker queue running in the background.
Re:Libdill: Structured Concurrency for C (2016)
by staticassertion on Tuesday June 01, 2021 @05:32PM
(#27361627)
If you don't wait for a response you're not really getting the same benefit.