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
Future
for thepending_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 nopending_unwind
is currently nested. This is useful to call inside a panic hook, because if there is somepending_unwind
call, future is permanently stuck inPoll::Pending
state. - pending_
unwind - Convert any panic during a
Future::poll
into 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_depth
to identify which thread panicked, and then cancel all futures associated with that thread.