Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Since you're mentionning it : i was surprised to find no golang "context" equivalent in rust's axum. How do you manage cancelling a long-running operation triggered inside an http request handler when the connection closes ? is it via RAII ?


Yeah due to the design rule that "futures do nothing unless polled", it's enough to simply drop them and it cancels the whole tree of work. That doesn't necessarily cancel other tasks that were spawned that the future might have been waiting on. That's really easy to build if it's needed, since we do have RAII. This is part of why Rust's futures compose really well in ways that goroutines just do not and JS promises struggle with.


Never thought of it like that. Super interesting, thanks.

Edit: isn't that the case for all "async" systems, in every language ?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: