Crate pending_unwind

Source
Expand description

Make any future non-unwinding. If Future::poll panics, it will be converted to Poll::Pending. One of the biggest problems with linear types is unwinding - what should you do duriing panic? They cannot be dropped, thus you cannot continue unwinding, and abort the program. This crate provides a way to convert unwinding to Poll::Pending, so you can handle it in your own way.

A web server may use this to cancel all futures associated with a thread that panicked without having catch_unwind.

Structs§

NestingDepth
Information about nesting depth of the poll.
NoUnwind
Future for the pending_unwind function. This future is fused.

Functions§

nesting_depth
This functions returns the nesting of [nounwind_poll] calls in this thread. NestingDepth(0) means that no pending_unwind is currently nested. This is useful to call inside a panic hook, because if there is some pending_unwind call, future is permanently stuck in Poll::Pending state.
pending_unwind
Convert any panic during a Future::poll into a Poll::Pending. Use panic hook to identify that panic happened and cancel the future on your own terms. For example, web server may use std::thread::current().id() and nesting_depth to identify which thread panicked, and then cancel all futures associated with that thread.