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§
- Nesting
Depth - Information about nesting depth of the poll.
- NoUnwind
Futurefor thepending_unwindfunction. This future is fused.
Functions§
- nesting_
depth - This functions returns the nesting of [
nounwind_poll] calls in this thread.NestingDepth(0)means that nopending_unwindis currently nested. This is useful to call inside a panic hook, because if there is somepending_unwindcall, future is permanently stuck inPoll::Pendingstate. - pending_
unwind - Convert any panic during a
Future::pollinto aPoll::Pending. Use panic hook to identify that panic happened and cancel the future on your own terms. For example, web server may usestd::thread::current().id()andnesting_depthto identify which thread panicked, and then cancel all futures associated with that thread.