News for hackers. Stuff that matters.
Re:Async Rust Is A Bad Language by nextaccountic on Friday September 08, 2023 @11:45PM (#37442083)
You can do that, but then the logic of your cancellable thread gets intermingled with the cancellation logic.

And since the cancellation logic runs on the cancellable thread, you can't really cancel a blocking operation. What you can do is to let it run to completion, check that it was canceled, and discard the value.

Re:Async Rust Is A Bad Language by kprotty on Saturday September 09, 2023 @05:29AM (#37443598)
Not sure I follow; the cancellation logic is on both threads/tasks 1) the operation itself waiting for either the result or a cancel notification and 2) the cancellation thread sending that notification.

The cancellation thread is generally the one doing the `select` so it spawns the operation thread(s) and waits for (one of) their results (i.e. through a channel/event). The others which lose the race are sent the cancellation signal and optionally joined if they need to be (i.e. they use intrusive memory).